diff --git a/DESCRIPTION b/DESCRIPTION index 19cf0dc..c563a14 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,7 +37,8 @@ Suggests: knitr, mockery, rmarkdown, - testthat (>= 3.0.0) + testthat (>= 3.0.0), + withr VignetteBuilder: knitr Config/testthat/edition: 3 diff --git a/tests/testthat.R b/tests/testthat.R index a2ad775..241a0f2 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -15,5 +15,6 @@ library(utils) library(tidyr) library(gridExtra) library(dplyr) +library(withr) test_check("browseMetadata") diff --git a/tests/testthat/test-browse_metadata.R b/tests/testthat/test-browse_metadata.R index 19fa44f..a8c6f91 100644 --- a/tests/testthat/test-browse_metadata.R +++ b/tests/testthat/test-browse_metadata.R @@ -2,7 +2,7 @@ test_that("browse_metadata function outputs files correctly", { # Setup - temp_dir <- withr::local_tempdir() + temp_dir <- local_tempdir() example_json_file <- system.file("inputs/national_community_child_health_database_(ncchd)_20240405T130125.json", package = "browseMetadata") # Execution @@ -26,4 +26,4 @@ test_that("browse_metadata function outputs files correctly", { expect_equal(nrow(bar_csv), 26) expect_equal(ncol(bar_csv),3) expect_equal(sum(bar_csv$N_Variables),318) -}) \ No newline at end of file +}) diff --git a/tests/testthat/test-copy_previous.R b/tests/testthat/test-copy_previous.R index 6a4358e..c254438 100644 --- a/tests/testthat/test-copy_previous.R +++ b/tests/testthat/test-copy_previous.R @@ -1,8 +1,8 @@ -# libraries: testthat, mockery, utils +# libraries: testthat, mockery, utils, withr test_that("copy_previous works correctly when there are files to copy from", { # Create a temporary directory - temp_dir <- withr::local_tempdir() + temp_dir <- local_tempdir() # Create test CSV files # Criteria for test files: one must have 'AUTO CATEGORISED' as Note, overlap in DataElements across files, different timestamps across files) diff --git a/tests/testthat/test-map_metadata.R b/tests/testthat/test-map_metadata.R index 77cfb73..580883b 100644 --- a/tests/testthat/test-map_metadata.R +++ b/tests/testthat/test-map_metadata.R @@ -1,8 +1,8 @@ -# libraries: testthat, mockery +# libraries: testthat, mockery, withr test_that("map_metadata function works correctly with user input", { # Setup - temp_dir <- withr::local_tempdir() + temp_dir <- local_tempdir() demo_log_output <- system.file("outputs/LOG_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv", package = "browseMetadata") demo_output <- system.file("outputs/OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv", package = "browseMetadata") diff --git a/tests/testthat/test-map_metadata_compare.R b/tests/testthat/test-map_metadata_compare.R index 6434a1c..ecab8c1 100644 --- a/tests/testthat/test-map_metadata_compare.R +++ b/tests/testthat/test-map_metadata_compare.R @@ -1,8 +1,8 @@ -# libraries: testthat, mockery +# libraries: testthat, mockery, withr test_that("map_metadata function works correctly with user input", { # Setup - temp_dir <- withr::local_tempdir() + temp_dir <- local_tempdir() demo_session_dir <- system.file("outputs", package = "browseMetadata") demo_session1_base <- "NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55" diff --git a/tests/testthat/test-map_metadata_convert.R b/tests/testthat/test-map_metadata_convert.R index 9fc97fa..6755e8d 100644 --- a/tests/testthat/test-map_metadata_convert.R +++ b/tests/testthat/test-map_metadata_convert.R @@ -1,8 +1,8 @@ -# libraries: testthat +# libraries: testthat, withr test_that("map_metadata_convert function outputs files correctly", { # Setup - temp_dir <- withr::local_tempdir() + temp_dir <- local_tempdir() file_in <- system.file("outputs/OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv", package = "browseMetadata") file_out <- system.file("outputs/L-OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv", package = "browseMetadata") @@ -18,4 +18,4 @@ test_that("map_metadata_convert function outputs files correctly", { # Test that the outputs are the same expect_equal(actual_output, expected_output) -}) \ No newline at end of file +})