From 326ce2a8cba8efc856fc038d30b4d12c1b640474 Mon Sep 17 00:00:00 2001 From: bubux Date: Sat, 20 Jul 2024 18:34:02 +0200 Subject: [PATCH] fix error tests for cran/ci --- DESCRIPTION | 4 +- .../api/catalogue/modifieddata-40eb64.R | 5 +++ tests/testthat/test_gen_alternative_terms.R | 21 +++++++++ tests/testthat/test_gen_catalogue.R | 35 +++++++++++++++ tests/testthat/test_gen_find.R | 29 ++++++++++++ tests/testthat/test_gen_meta_data.R | 23 ++++++++++ tests/testthat/test_gen_modified_data.R | 25 +++++++++++ tests/testthat/test_gen_objects2stat.R | 45 +++++++++++++------ tests/testthat/test_gen_objects2var.R | 45 +++++++++++++------ tests/testthat/test_gen_search_vars.R | 26 +++++++++++ tests/testthat/test_gen_val2var.R | 26 +++++++++++ tests/testthat/test_gen_var2stat.R | 35 +++++++++++++++ 12 files changed, 290 insertions(+), 29 deletions(-) create mode 100644 tests/testthat/modified2/api/catalogue/modifieddata-40eb64.R diff --git a/DESCRIPTION b/DESCRIPTION index 8749078..dc65f87 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,5 @@ Package: restatis -Title: R Wrapper to access a wide range of Germany's Federal Statistical System - databases based on the GENESIS Web Service RESTful API of the German - Federal Statistical Office (Statistisches Bundesamt/Destatis) +Title: R Wrapper to Access a Wide Range of Germany's Federal Statistical System Databases Based on the GENESIS Web Service RESTful API of the German Federal Statistical Office (Statistisches Bundesamt/Destatis) Version: 0.2.0 Authors@R: c( person("Yannik", "Buhl", , "ybuhl@posteo.de", role = c("aut", "cre")), diff --git a/tests/testthat/modified2/api/catalogue/modifieddata-40eb64.R b/tests/testthat/modified2/api/catalogue/modifieddata-40eb64.R new file mode 100644 index 0000000..745112b --- /dev/null +++ b/tests/testthat/modified2/api/catalogue/modifieddata-40eb64.R @@ -0,0 +1,5 @@ +structure(list(method = "GET", url = "/api/catalogue/modifieddata?username=ABCDEF&password=1234abcd&username=ABCDEF&password=1234abcdselection=61111&type=all&date=20.07.2024", + status_code = 404L, headers = structure(list(Date = "Sat, 20 Jul 2024 16:13:04 GMT", + Server = "Apache", `Content-Length` = "106", `Content-Type` = "application/json"), class = "httr2_headers"), + body = charToRaw("{\"Code\":2,\"Content\":\"Ein Fehler ist aufgetreten. (Bitte geben Sie Ihren Nutzernamen ein.)\",\"Type\":\"ERROR\"}"), + cache = new.env(parent = emptyenv())), class = "httr2_response") diff --git a/tests/testthat/test_gen_alternative_terms.R b/tests/testthat/test_gen_alternative_terms.R index 14f94ed..2d3e27f 100644 --- a/tests/testthat/test_gen_alternative_terms.R +++ b/tests/testthat/test_gen_alternative_terms.R @@ -20,6 +20,7 @@ with_mock_dir("terms1", { expect_true("Copyright" %in% names(attrs)) }) + }) #------------------------------------------------------------------------------- @@ -27,26 +28,46 @@ with_mock_dir("terms1", { #------------------------------------------------------------------------------- test_that("search term errors on multiple codes", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_alternative_terms(term = c("611*", "711*"), database = "genesis"), regexp = "Parameter 'term' must be a single string.") + }) test_that("search term errors on too long search term", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_alternative_terms(term = "dies das ananas!", database = "genesis"), regexp = "Parameter 'term' cannot consist of more than 15 characters.") + }) test_that("search term errors on wrong parameter type", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_alternative_terms(term = "Krankenhaus", similarity = 1, database = "genesis"), regexp = "Parameter 'similarity' has to be of type 'logical'.") + }) test_that("search term errors on wrong parameter type", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_alternative_terms(term = 1992, similarity = TRUE, database = "genesis"), regexp = "Parameter 'term' has to be of type 'character'.") + }) diff --git a/tests/testthat/test_gen_catalogue.R b/tests/testthat/test_gen_catalogue.R index 49e1579..9e36fae 100644 --- a/tests/testthat/test_gen_catalogue.R +++ b/tests/testthat/test_gen_catalogue.R @@ -56,7 +56,9 @@ with_mock_dir("catalogue3", { error.ignore = FALSE, database = "genesis"), regexp = "No object found for your request") + }) + }) #------------------------------------------------------------------------------- @@ -91,7 +93,9 @@ with_mock_dir("catalogue5", { error.ignore = TRUE, database = "genesis"), regexp = "Use 'error.ignore = FALSE' to stop the function at the point where no object could be found.") + }) + }) #------------------------------------------------------------------------------- @@ -99,15 +103,24 @@ with_mock_dir("catalogue5", { #------------------------------------------------------------------------------- test_that("gen_catalogue function errors on multiple codes", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_catalogue(code = c("611*", "711*"), detailed = TRUE, category = "tables", database = "genesis"), regexp = "Parameter 'code' must be a single string.") + }) test_that("gen_catalogue function errors on numeric code param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_catalogue(code = 12345, detailed = TRUE, @@ -119,32 +132,47 @@ test_that("gen_catalogue function errors on numeric code param", { #------------------------------------------------------------------------------- test_that("gen_catalogue function errors on wrong categories", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_catalogue(code = "611*", detailed = TRUE, category = "variables", database = "genesis"), regexp = "Available categories are 'tables', 'statistics', and 'cubes'.") + }) test_that("gen_catalogue function errors on too many categories", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_catalogue(code = "611*", detailed = TRUE, category = c("variables", "statistics", "tables", "cubes"), database = "genesis"), regexp = "Parameter 'category' has to have a length of 1 to 3.") + }) #------------------------------------------------------------------------------- test_that("gen_catalogue function errors on numeric detailed param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_catalogue(code = "711*", detailed = 1, category = "tables", database = "genesis"), regexp = "Parameter 'detailed' has to be of type 'logical' and of length 1.") + }) with_mock_dir("catalogue6", { @@ -159,12 +187,18 @@ with_mock_dir("catalogue6", { category = "tables", database = "genesis"), regexp = "Use 'detailed = TRUE' to obtain the complete output.") + }) + }) #------------------------------------------------------------------------------- test_that("gen_catalogue function errors on wrong error.ignore param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_catalogue(code = "711*", detailed = TRUE, @@ -172,5 +206,6 @@ test_that("gen_catalogue function errors on wrong error.ignore param", { error.ignore = 1, database = "genesis"), regexp = "Parameter 'error.ignore' has to be of type 'logical' and of length 1.") + }) diff --git a/tests/testthat/test_gen_find.R b/tests/testthat/test_gen_find.R index bfe9c5f..f1640cc 100644 --- a/tests/testthat/test_gen_find.R +++ b/tests/testthat/test_gen_find.R @@ -22,7 +22,9 @@ with_mock_dir("find1", { expect_true("Language" %in% names(attrs)) expect_true("Pagelength" %in% names(attrs)) expect_true("Copyright" %in% names(attrs)) + }) + }) #------------------------------------------------------------------------------- @@ -40,7 +42,9 @@ with_mock_dir("find2_fake", { expect_error( gen_find(term = "bus", error.ignore = TRUE, database = "genesis"), regexp = "test error message") + }) + }) #------------------------------------------------------------------------------- @@ -64,31 +68,56 @@ with_mock_dir("find3", { #------------------------------------------------------------------------------- test_that("gen_find function errors on numeric term param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_find(term = 12345, detailed = TRUE, category = "tables", database = "genesis"), regexp = "Parameter 'term' has to be of type 'character'.") + }) test_that("gen_find function errors on wrong category", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_find(term = "bus", detailed = TRUE, category = "table", database = "genesis"), regexp = "Available categories for parameter 'category' for 'genesis' database are 'all', 'tables', 'statistics', 'variables', and 'cubes'.") + }) test_that("gen_find function errors on wrong detailed param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_find(term = "bus", detailed = 1, category = "tables", database = "genesis"), regexp = "Parameter 'detailed' has to be of type 'logical' and of length 1.") + }) test_that("gen_find function errors on wrong ordering param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_find(term = "bus", ordering = 1, category = "tables", database = "genesis"), regexp = "Parameter 'ordering' has to be of type 'logical' and of length 1.") + }) test_that("gen_find function errors on wrong error.ignore param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_find(term = "bus", error.ignore = 1, category = "tables", database = "genesis"), regexp = "Parameter 'error.ignore' has to be of type 'logical' and of length 1.") + }) diff --git a/tests/testthat/test_gen_meta_data.R b/tests/testthat/test_gen_meta_data.R index d93636d..45ab4e9 100644 --- a/tests/testthat/test_gen_meta_data.R +++ b/tests/testthat/test_gen_meta_data.R @@ -43,7 +43,9 @@ with_mock_dir("meta2_fake", { category = "cube", database = "genesis"), regexp = "test error message") + }) + }) #------------------------------------------------------------------------------- @@ -60,7 +62,9 @@ with_mock_dir("meta3", { error.ignore = TRUE, database = "genesis"), regexp = "Use 'error.ignore = FALSE' to stop the function at the point where no object could be found.") + }) + }) #------------------------------------------------------------------------------- @@ -68,18 +72,32 @@ with_mock_dir("meta3", { #------------------------------------------------------------------------------- test_that("gen_metadata function errors on numeric code param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_metadata(code = 12345, category = "Table", database = "genesis"), regexp = "Parameter 'code' has to be of type 'character'.") + }) test_that("gen_metadata function errors on multiple categories", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_metadata(code = "12345", category = c("Table", "Cube"), database = "genesis"), regexp = "Parameter 'category' must have a length of 1. Please specify the category.") + }) test_that("gen_metadata function errors on wrong category", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_metadata(code = "11111", category = "Table", database = "genesis"), regexp = "Available categories for parameter 'category' for 'genesis' database are 'cube', 'table', 'statistic', 'variable', and 'value'") @@ -87,7 +105,12 @@ test_that("gen_metadata function errors on wrong category", { }) test_that("gen_metadata function errors on wrong error.ignore param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_metadata(code = "11111", error.ignore = 1, category = "table", database = "genesis"), regexp = "Parameter 'error.ignore' has to be of type 'logical' and of length 1.") + }) diff --git a/tests/testthat/test_gen_modified_data.R b/tests/testthat/test_gen_modified_data.R index 37114a1..e199b25 100644 --- a/tests/testthat/test_gen_modified_data.R +++ b/tests/testthat/test_gen_modified_data.R @@ -72,35 +72,60 @@ with_mock_dir("modified4_fake", { #------------------------------------------------------------------------------- test_that("gen_modified_data errors on misspecified dates", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_modified_data(code = "61111", date = "1.1.2022"), regexp = "it has to be of length 1 and format DD.MM.YYYY") + }) test_that("gen_modified_data errors on misspecified dates", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_modified_data(code = "61111", date = 23456), regexp = "'date', it has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_modified_data errors on multiple codes", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_modified_data(code = c("611*", "711*")), regexp = "Parameter 'code' must be a single string.") + }) test_that("gen_modified_data function errors on numeric code param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_modified_data(code = 12345), regexp = "Parameter 'code' has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_modified_data function errors on wrong type value", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_modified_data(code = "12345", type = "diesdasananas"), regexp = "'arg' should be one of") + }) diff --git a/tests/testthat/test_gen_objects2stat.R b/tests/testthat/test_gen_objects2stat.R index 9ac5e1d..17f6eeb 100644 --- a/tests/testthat/test_gen_objects2stat.R +++ b/tests/testthat/test_gen_objects2stat.R @@ -20,6 +20,7 @@ with_mock_dir("xy_statistic1", { expect_true("Copyright" %in% names(attrs)) }) + }) #------------------------------------------------------------------------------- @@ -34,7 +35,9 @@ with_mock_dir("xy_statistic2", { category = "tables", database = "genesis"), class = "data.frame") + }) + }) #------------------------------------------------------------------------------- @@ -42,38 +45,63 @@ with_mock_dir("xy_statistic2", { #------------------------------------------------------------------------------- test_that("gen_objects2stat function errors on multiple codes", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2stat(code = c("611*", "711*"), detailed = TRUE, category = "tables", database = "genesis"), regexp = "Parameter 'code' must be a single string.") + }) test_that("gen_objects2stat function errors on numeric code param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2stat(code = 12345, detailed = TRUE, category = "tables", database = "genesis"), regexp = "Parameter 'code' has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_objects2stat function errors on wrong categories", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2stat(code = "611*", detailed = TRUE, category = "statistics", database = "genesis"), regexp = "Available categories are 'tables', 'variables', and 'cubes'.") + }) test_that("gen_objects2stat function errors on too many categories", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2stat(code = "611*", detailed = TRUE, category = c("variables", "statistics", "tables", "cubes"), database = "genesis"), regexp = "Parameter 'category' has to have a length of 1 to 3.") + }) #------------------------------------------------------------------------------- test_that("gen_objects2stat function errors on numeric detailed param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2stat(code = "711*", detailed = 1, category = "tables", database = "genesis"), regexp = "Parameter 'detailed' has to be of type 'logical' and of length 1.") + }) with_mock_dir("xy_statistic3", { @@ -92,22 +120,13 @@ with_mock_dir("xy_statistic3", { #------------------------------------------------------------------------------- -# test_that("gen_objects2stat function errors on wrong sort param", { -# expect_error( -# gen_objects2stat(code = "61111", sortcriterion = "date"), -# regexp = "Parameter 'sortcriterion' has to be 'code' or 'content'.") -# }) - -# test_that("gen_objects2stat function errors on wrong sort param type", { -# expect_error( -# gen_objects2stat(code = "6111*", sortcriterion = 123), -# regexp = "Parameter 'sortcriterion' has to be of type 'character'.") -# }) +test_that("gen_objects2stat function errors on wrong error.ignore param", { -#------------------------------------------------------------------------------- + skip_on_cran() + skip_on_ci() -test_that("gen_objects2stat function errors on wrong error.ignore param", { expect_error( gen_objects2stat(code = "711*", error.ignore = 1), regexp = "Parameter 'error.ignore' has to be of type 'logical' and of length 1.") + }) diff --git a/tests/testthat/test_gen_objects2var.R b/tests/testthat/test_gen_objects2var.R index 7a39a2a..ad2ccc9 100644 --- a/tests/testthat/test_gen_objects2var.R +++ b/tests/testthat/test_gen_objects2var.R @@ -20,6 +20,7 @@ with_mock_dir("xy_variable1", { expect_true("Copyright" %in% names(attrs)) }) + }) #------------------------------------------------------------------------------- @@ -45,38 +46,63 @@ with_mock_dir("xy_variable2", { #------------------------------------------------------------------------------- test_that("gen_objects2var function errors on multiple codes", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2var(code = c("DLAND", "LAND"), detailed = TRUE, category = "tables"), regexp = "Parameter 'code' must be a single string.") + }) test_that("gen_objects2var function errors on numeric code param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2var(code = 12345, detailed = TRUE, category = "tables"), regexp = "Parameter 'code' has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_objects2var function errors on wrong categories", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2var(code = "DLAND", detailed = TRUE, category = "variables", database = "genesis"), regexp = "Available categories are 'tables', 'statistics', and 'cubes'.") + }) test_that("gen_objects2var function errors on too many categories", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2var(code = "611*", detailed = TRUE, category = c("variables", "statistics", "tables", "cubes")), regexp = "Parameter 'category' has to have a length of 1 to 3.") + }) #------------------------------------------------------------------------------- test_that("gen_objects2var function errors on numeric detailed param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_objects2var(code = "DLAND", detailed = 1, category = "tables"), regexp = "Parameter 'detailed' has to be of type 'logical' and of length 1.") + }) with_mock_dir("xy_variable3", { @@ -88,27 +114,20 @@ with_mock_dir("xy_variable3", { expect_message( gen_objects2var(code = "DLAND", detailed = FALSE, category = "tables", database = "genesis"), regexp = "Use 'detailed = TRUE' to obtain the complete output.") + }) + }) #------------------------------------------------------------------------------- -# test_that("gen_objects2var function errors on wrong sort param", { -# expect_error( -# gen_objects2var(code = "DLAND", sortcriterion = "date"), -# regexp = "Parameter 'sortcriterion' has to be 'code' or 'content'.") -# }) - -# test_that("gen_objects2var function errors on wrong sort param type", { -# expect_error( -# gen_objects2var(code = "DLAND", sortcriterion = 123), -# regexp = "Parameter 'sortcriterion' has to be of type 'character'.") -# }) +test_that("gen_objects2var function errors on wrong error.ignore param", { -#------------------------------------------------------------------------------- + skip_on_cran() + skip_on_ci() -test_that("gen_objects2var function errors on wrong error.ignore param", { expect_error( gen_objects2var(code = "7DLAND", error.ignore = 1), regexp = "Parameter 'error.ignore' has to be of type 'logical' and of length 1.") + }) diff --git a/tests/testthat/test_gen_search_vars.R b/tests/testthat/test_gen_search_vars.R index a0ca3b8..1745b23 100644 --- a/tests/testthat/test_gen_search_vars.R +++ b/tests/testthat/test_gen_search_vars.R @@ -41,6 +41,7 @@ with_mock_dir("searchvars2", { database = "genesis", language = "en"), regexp = "No object found for your request.") + }) }) @@ -50,36 +51,61 @@ with_mock_dir("searchvars2", { #------------------------------------------------------------------------------- test_that("gen_search_vars function errors on multiple codes", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_search_vars(code = c("611*", "711*"), detailed = TRUE, category = "tables"), regexp = "Parameter 'code' must be a single string.") + }) test_that("gen_search_vars function errors on numeric code param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_search_vars(code = 12345, detailed = TRUE, category = "tables"), regexp = "Parameter 'code' has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_search_vars function errors on wrong sort param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_search_vars(code = "61111", sortcriterion = "date"), regexp = "Parameter 'sortcriterion' has to be 'code' or 'content'.") + }) test_that("gen_search_vars function errors on wrong sort param type", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_search_vars(code = "6111*", sortcriterion = 123), regexp = "Parameter 'sortcriterion' has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_search_vars function errors on wrong error.ignore param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_search_vars(code = "711*", error.ignore = 1), regexp = "Parameter 'error.ignore' has to be of type 'logical' and of length 1.") + }) diff --git a/tests/testthat/test_gen_val2var.R b/tests/testthat/test_gen_val2var.R index c11ff23..7adbeed 100644 --- a/tests/testthat/test_gen_val2var.R +++ b/tests/testthat/test_gen_val2var.R @@ -43,6 +43,7 @@ with_mock_dir("values2", { expect_true("Copyright" %in% names(attrs)) }) + }) #------------------------------------------------------------------------------- @@ -50,36 +51,61 @@ with_mock_dir("values2", { #------------------------------------------------------------------------------- test_that("gen_val2var function errors on multiple codes", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_val2var(code = c("611*", "711*"), detailed = TRUE, category = "tables", database = "genesis"), regexp = "Parameter 'code' must be a single string.") + }) test_that("gen_val2var function errors on numeric code param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_val2var(code = 12345, detailed = TRUE, category = "tables", "genesis"), regexp = "Parameter 'code' has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_val2var function errors on wrong sort param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_val2var(code = "61111", sortcriterion = "date", database = "genesis"), regexp = "Parameter 'sortcriterion' has to be 'code' or 'content'.") + }) test_that("gen_val2var function errors on wrong sort param type", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_val2var(code = "6111*", sortcriterion = 123, database = "genesis"), regexp = "Parameter 'sortcriterion' has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_val2var function errors on wrong error.ignore param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_val2var(code = "711*", error.ignore = 1, database = "genesis"), regexp = "Parameter 'error.ignore' has to be of type 'logical' and of length 1.") + }) diff --git a/tests/testthat/test_gen_var2stat.R b/tests/testthat/test_gen_var2stat.R index 7514830..a1abac3 100644 --- a/tests/testthat/test_gen_var2stat.R +++ b/tests/testthat/test_gen_var2stat.R @@ -23,6 +23,7 @@ with_mock_dir("variables1", { expect_true("Copyright" %in% names(attrs)) }) + }) #------------------------------------------------------------------------------- @@ -40,7 +41,9 @@ with_mock_dir("variables2_fake", { expect_error( gen_var2stat(code = "74111", database = "genesis"), regexp = "test error message") + }) + }) #------------------------------------------------------------------------------- @@ -48,23 +51,38 @@ with_mock_dir("variables2_fake", { #------------------------------------------------------------------------------- test_that("gen_var2stat function errors on multiple codes", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_var2stat(code = c("611*", "711*"), detailed = TRUE, category = "tables"), regexp = "Parameter 'code' must be a single string.") + }) test_that("gen_var2stat function errors on numeric code param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_var2stat(code = 12345, detailed = TRUE, category = "tables"), regexp = "Parameter 'code' has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_var2stat function errors on numeric detailed param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_var2stat(code = "711*", detailed = 1, category = "tables"), regexp = "Parameter 'detailed' has to be of type 'logical' and of length 1.") + }) with_mock_dir("variables3", { @@ -76,27 +94,44 @@ with_mock_dir("variables3", { expect_message( gen_var2stat(code = "61111", detailed = FALSE, category = "tables", database = "genesis"), regexp = "Use 'detailed = TRUE' to obtain the complete output.") + }) + }) #------------------------------------------------------------------------------- test_that("gen_var2stat function errors on wrong sort param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_var2stat(code = "61111", sortcriterion = "date"), regexp = "Parameter 'sortcriterion' has to be 'code' or 'content'.") + }) test_that("gen_var2stat function errors on wrong sort param type", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_var2stat(code = "6111*", sortcriterion = 123), regexp = "Parameter 'sortcriterion' has to be of type 'character'.") + }) #------------------------------------------------------------------------------- test_that("gen_var2stat function errors on wrong error.ignore param", { + + skip_on_cran() + skip_on_ci() + expect_error( gen_var2stat(code = "711*", error.ignore = 1), regexp = "Parameter 'error.ignore' has to be of type 'logical' and of length 1.") + })