From 8485243bf28ce938c6f479d49af0f98ced738516 Mon Sep 17 00:00:00 2001 From: Eli Miller Date: Sun, 22 Dec 2024 14:55:54 -0600 Subject: [PATCH] =?UTF-8?q?Per=20#269,=20updated=20the=20messaging=20in=20?= =?UTF-8?q?'xportr=5Forder()`=20to=20fix=20a=20mistatem=E2=80=A6=20(#279)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Per #269, updated the messaging in 'xportr_order()` to fix a mistatement. The function is concerned about if variables in the dataset aren't in the specifiation file, not the other way around. * Fix metadata test --- NEWS.md | 3 +++ R/messages.R | 2 +- tests/testthat/test-metadata.R | 2 +- tests/testthat/test-order.R | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9e1c4ce4..edb7c129 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # xportr (development version) +* Updated order messaging to clarify some messaging when all data in dataset is +found in the specification. (#269) + * `"hms"` was added to the default value of the `xportr.numeric_types` option. This ensures that `{xportr}` works smoothly with variables created by `admiral::derive_vars_dtm_to_tm()`. (#271) diff --git a/R/messages.R b/R/messages.R index 3ab774ef..89dd77e3 100644 --- a/R/messages.R +++ b/R/messages.R @@ -198,7 +198,7 @@ var_ord_msg <- function(reordered_vars, moved_vars, verbose) { ) xportr_logger(message, verbose) } else { - cli_h2("All variables in specification file are in dataset") + cli_h2("All variables in dataset are found in `metadata`") } if (length(reordered_vars) > 0) { diff --git a/tests/testthat/test-metadata.R b/tests/testthat/test-metadata.R index 49f49a6c..9e7e263a 100644 --- a/tests/testthat/test-metadata.R +++ b/tests/testthat/test-metadata.R @@ -624,7 +624,7 @@ test_that("metadata Test 29: Variable ordering messaging is correct", { # Metadata versions xportr_metadata(df, df_meta, domain = "df", verbose = "message") %>% xportr_order() %>% - expect_message("All variables in specification file are in dataset") %>% + expect_message("All variables in dataset are found in `metadata`") %>% expect_condition("4 reordered in dataset") %>% expect_message("Variable reordered in `.df`: `a`, `b`, `c`, and `d`") diff --git a/tests/testthat/test-order.R b/tests/testthat/test-order.R index 8aaa4dc6..6368af3e 100644 --- a/tests/testthat/test-order.R +++ b/tests/testthat/test-order.R @@ -137,7 +137,7 @@ test_that("order Test 8: Variable ordering messaging is correct", { local_cli_theme() suppressMessages( xportr_order(df, df_meta, verbose = "message", domain = "df") %>% - expect_message("All variables in specification file are in dataset") %>% + expect_message("All variables in dataset are found in `metadata`") %>% expect_condition("4 reordered in dataset") %>% expect_message("Variable reordered in `.df`: `a`, `b`, `c`, and `d`") ) @@ -172,13 +172,13 @@ test_that("order Test 10: Gets warning when metadata has multiple rows with same # Checks that message appears when xportr.domain_name is invalid suppressMessages(multiple_vars_in_spec_helper(xportr_order) %>% # expect_message() are being caught to provide clean test without output #nolint - expect_message("All variables in specification file are in dataset") %>% + expect_message("All variables in dataset are found in `metadata`") %>% expect_message("All variables in dataset are ordered")) # Checks that message doesn't appear when xportr.domain_name is valid suppressMessages(multiple_vars_in_spec_helper2(xportr_order) %>% # expect_message() are being caught to provide clean test without output #nolint - expect_message("All variables in specification file are in dataset") %>% + expect_message("All variables in dataset are found in `metadata`") %>% expect_message("All variables in dataset are ordered")) })