From 11fbc94fae081ae4087b392a79f51c342a22260b Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Thu, 11 Apr 2024 13:31:53 -0700 Subject: [PATCH] added snapshot --- tests/testthat/_snaps/assertions.md | 9 +++++++++ tests/testthat/test-assertions.R | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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 })