diff --git a/DESCRIPTION b/DESCRIPTION index 0a3607c..7a5e100 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: workflow.pacta Title: Run PACTA -Version: 0.0.0.9011 +Version: 0.0.0.9012 Authors@R: c(person(given = "CJ", family = "Yetman", diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 0000000..00770a9 --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1,13 @@ +## save current settings so that we can reset later + +## Logger Settings +# Set threshold to OFF, and capture previous state +logger_threshold <- logger::log_threshold("OFF") + +## Tear down function +withr::defer( + expr = { + logger::log_threshold(logger_threshold) + }, + envir = teardown_env() +) diff --git a/tests/testthat/test-analysis_prechecks.R b/tests/testthat/test-analysis_prechecks.R index 0fd5b90..150afd5 100644 --- a/tests/testthat/test-analysis_prechecks.R +++ b/tests/testthat/test-analysis_prechecks.R @@ -1,18 +1,3 @@ -## save current settings so that we can reset later -threshold <- logger::log_threshold() -appender <- logger::log_appender() -layout <- logger::log_layout() -on.exit({ - ## reset logger settings - logger::log_threshold(threshold) - logger::log_layout(layout) - logger::log_appender(appender) -}) - -logger::log_appender(logger::appender_stdout) -logger::log_threshold(logger::FATAL) -logger::log_layout(logger::layout_simple) - test_that("audit_prechecks works when all files are present", { pacta_data_dir <- withr::local_tempdir() filenames <- c( diff --git a/tests/testthat/test-audit_prechecks.R b/tests/testthat/test-audit_prechecks.R index 500b43e..60f2054 100644 --- a/tests/testthat/test-audit_prechecks.R +++ b/tests/testthat/test-audit_prechecks.R @@ -1,18 +1,3 @@ -## save current settings so that we can reset later -threshold <- logger::log_threshold() -appender <- logger::log_appender() -layout <- logger::log_layout() -on.exit({ - ## reset logger settings - logger::log_threshold(threshold) - logger::log_layout(layout) - logger::log_appender(appender) -}) - -logger::log_appender(logger::appender_stdout) -logger::log_threshold(logger::FATAL) -logger::log_layout(logger::layout_simple) - test_that("audit_prechecks works when all files are present", { pacta_data_dir <- withr::local_tempdir() filenames <- c( diff --git a/tests/testthat/test-calc_weights_prechecks.R b/tests/testthat/test-calc_weights_prechecks.R index 1e3ba9e..e224ce3 100644 --- a/tests/testthat/test-calc_weights_prechecks.R +++ b/tests/testthat/test-calc_weights_prechecks.R @@ -1,18 +1,3 @@ -## save current settings so that we can reset later -threshold <- logger::log_threshold() -appender <- logger::log_appender() -layout <- logger::log_layout() -on.exit({ - ## reset logger settings - logger::log_threshold(threshold) - logger::log_layout(layout) - logger::log_appender(appender) -}) - -logger::log_appender(logger::appender_stdout) -logger::log_threshold(logger::FATAL) -logger::log_layout(logger::layout_simple) - test_that("audit_prechecks works when all files are present", { data_dir <- withr::local_tempdir() filenames <- c(