From a394430076ac11b8d7c259c07f3623feb41aac96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Todor=20Kondi=C4=87?= <kontrapunkt@uclmail.net> Date: Fri, 17 Feb 2023 16:15:07 +0100 Subject: [PATCH] tests: Updated. --- tests/testthat/helper.R | 21 +++++++++++++++++++++ tests/testthat/test-api.R | 6 ++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index e1e0bcf..ab43777 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 7f9b16e..5968750 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") })}) -- GitLab