Skip to content

Commit

Permalink
validate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Polkas committed Oct 20, 2023
1 parent 692c798 commit 4234a2e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Binary file modified tests/testthat/Rplots.pdf
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/testthat/test-cat2cat_validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@ testthat::test_that("validate_mappings correct", {

testthat::test_that("validate_data incorrect", {
testthat::expect_error(validate_data(list()), 'inherits\\(data\\$old, "data.frame"\\) is not TRUE')

data_simple <- list(old = occup_old, new = occup_new, cat_var_old = "code", cat_var_new = "code", time_var = "WRONG")

testthat::expect_error(
validate_data(data_simple),
'all\\(c\\(data\\$cat_var_old, data\\$time_var\\) \\%in\\% colnames\\(data\\$old\\)\\) is not TRUE'
)

data_simple <- list(old = occup_old, new = occup_new, cat_var_old = "WRONG", cat_var_new = "code", time_var = "year")

testthat::expect_error(
validate_data(data_simple),
'all\\(c\\(data\\$cat_var_old, data\\$time_var\\) \\%in\\% colnames\\(data\\$old\\)\\) is not TRUE'
)

data_simple <- list(old = occup_old, new = occup_new, cat_var_old = "code", cat_var_new = "WRONG", time_var = "year")

testthat::expect_error(
validate_data(data_simple),
'all\\(c\\(data\\$cat_var_new, data\\$time_var\\) \\%in\\% colnames\\(data\\$new\\)\\) is not TRUE'
)

})

testthat::test_that("validate_data correct", {
Expand Down

0 comments on commit 4234a2e

Please sign in to comment.