diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index e1e0bcf942722a5d14483a962cc3035aea9ffb06..ab43777471a6e3035a8e77c0556e33151c66cfac 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -1,3 +1,24 @@ ok_return_val <- function(fun_name,...) { testthat::test_that(paste("function",fun_name,"returns correct result."),...) } + +gen_test_dirs <- function() { + + tname = tempfile("shiny_test_dirs") + dirs = list(metfrag_db_dir = file.path(tname,"mfdb")) + dirs$top_data_dir = file.path(tname,"topdatadir") + dirs$projects = file.path(tname,"projects") + dir.create(tname) + for (dr in dirs) dir.create(dr) + dirs$root = tname + fn_db = system.file("testdata","example_db.csv",package="shinyscreen") + dirs +} + + +gen_test_project <- function() { + dirs = gen_test_dirs() + project = file.path(dirs$projects,"test_project") + dir.create(project) + +} diff --git a/tests/testthat/test-api.R b/tests/testthat/test-api.R index 7f9b16e2ee2092059c0dfc0a67dd275594ae3815..59687506c5a26c41803a5c19fb0a3b1c37305f53 100644 --- a/tests/testthat/test-api.R +++ b/tests/testthat/test-api.R @@ -11,11 +11,13 @@ test_that("Preparation for app start",{withr::with_tempdir({ saveRDS("",file=mrt) expect_error(prepare_app(dir_before=dbef, projects="absent", - top_data_dir=ddata), + top_data_dir=ddata, + metfrag_db_dir=""), class="projects-absent") expect_error(prepare_app(dir_before=dbef, projects=dproj, - top_data_dir="absent"), + top_data_dir="absent", + metfrag_db_dir=""), class="top-data-dir-absent") })})