diff --git a/tests/testthat/_snaps/assertions.md b/tests/testthat/_snaps/assertions.md index a2809dbb..268fa13a 100644 --- a/tests/testthat/_snaps/assertions.md +++ b/tests/testthat/_snaps/assertions.md @@ -261,6 +261,15 @@ ! List element "val" must be `>=0` in argument `input`: i But, `input[[2]]$val = -1`, and `input[[3]]$val = -2` +# assert_one_to_one Test 84: error if there is a one to many mapping + + Code + assert_one_to_one(pharmaversesdtm::dm, exprs(DOMAIN), exprs(USUBJID)) + Condition + Error: + ! For some values of "DOMAIN" there is more than one value of "USUBJID" + i Call `get_one_to_many_dataset()` to get all one-to-many values. + # assert_date_var Test 86: error if variable is not a date or datetime variable Code diff --git a/tests/testthat/test-assertions.R b/tests/testthat/test-assertions.R index 87633c45..e75fb951 100644 --- a/tests/testthat/test-assertions.R +++ b/tests/testthat/test-assertions.R @@ -1268,6 +1268,13 @@ test_that("assert_list_element Test 83: error if the elements do not fulfill the ## Test 84: error if there is a one to many mapping ---- test_that("assert_one_to_one Test 84: error if there is a one to many mapping", { expect_error( + assert_one_to_one(pharmaversesdtm::dm, exprs(DOMAIN), exprs(USUBJID)), + class = "assert_one_to_one" + ) + admiraldev_environment$one_to_many <- NULL + + expect_snapshot( + error = TRUE, assert_one_to_one(pharmaversesdtm::dm, exprs(DOMAIN), exprs(USUBJID)) ) admiraldev_environment$one_to_many <- NULL @@ -1276,7 +1283,8 @@ test_that("assert_one_to_one Test 84: error if there is a one to many mapping", ## Test 85: error if there is a many to one mapping ---- test_that("assert_one_to_one Test 85: error if there is a many to one mapping", { expect_error( - assert_one_to_one(pharmaversesdtm::dm, exprs(USUBJID), exprs(DOMAIN)) + assert_one_to_one(pharmaversesdtm::dm, exprs(USUBJID), exprs(DOMAIN)), + class = "assert_one_to_one" ) admiraldev_environment$many_to_one <- NULL })