diff --git a/tests/testthat/test-check_functions.R b/tests/testthat/test-check_functions.R index 77bb788..fe3a239 100644 --- a/tests/testthat/test-check_functions.R +++ b/tests/testthat/test-check_functions.R @@ -1,21 +1,23 @@ test_that("test no error when running folder function", { - if (testthat::testing_package() != ""){ - path <- dirname(dirname(getwd())) - }else{ - path <- getwd() - } + #if (testthat::testing_package() != ""){ + # path <- dirname(dirname(getwd())) + #}else{ + # path <- getwd() + #} testthat::expect_silent( assertHE::tabulate_functions_in_folder( - path = path, + path = testthat::test_path("."), + path_exclude = NULL, collapse = T, packages_to_exclude = c("base", "stats", "utils") ) ) tmp <- assertHE::tabulate_functions_in_folder( - path = path, + path = testthat::test_path("."), + path_exclude = NULL, collapse = T, packages_to_exclude = c("base", "stats", "utils") ) @@ -25,7 +27,8 @@ test_that("test no error when running folder function", { testthat::expect_type( assertHE::tabulate_functions_in_folder( - path = path, + path = testthat::test_path("."), + path_exclude = NULL, collapse = F, packages_to_exclude = c("base", "stats", "utils") ), @@ -35,7 +38,8 @@ test_that("test no error when running folder function", { testthat::expect_type( assertHE::tabulate_functions_in_folder( - path = path, + path = testthat::test_path("."), + path_exclude = NULL, collapse = F, packages_to_exclude = NULL ), @@ -49,16 +53,16 @@ test_that("test no error when running folder function", { test_that("find_test can identify a test where it exists", { - if (testthat::testing_package() != ""){ - path <- dirname(dirname(getwd())) - }else{ - path <- getwd() - } + #if (testthat::testing_package() != ""){ + # path <- dirname(dirname(getwd())) + #}else{ + # path <- getwd() + #} #if(testthat::testing_package() == ""){ path_to_test1 <- assertHE:::find_test(v_functions = "check_markov_trace", - path = path, + path = testthat::test_path("example_project"), test_path = "tests/testthat") testthat::expect_length(object = path_to_test1, n = 1) @@ -66,7 +70,7 @@ test_that("find_test can identify a test where it exists", { path_to_test2 <- assertHE:::find_test( v_functions = c("check_trans_prob_array", "mean"), - path = path, + path = testthat::test_path("example_project"), test_path = "tests/testthat" ) @@ -87,17 +91,17 @@ test_that("find_test can identify a test where it exists", { test_that( "tabulate_functions_in_folder_with_tests can identify functions, packages and test locations", { - if (testthat::testing_package() != "") { - path <- dirname(dirname(getwd())) - } else{ - path <- getwd() - } + # if (testthat::testing_package() != "") { + # path <- dirname(dirname(getwd())) + # } else{ + # path <- getwd() + # } #if(testthat::testing_package() == ""){ testthat::expect_silent( assertHE:::tabulate_functions_in_folder_with_tests( - path = path, - path_exclude = "tests/testthat", + path = testthat::test_path("example_project"), + path_exclude = NULL, packages_to_exclude = c("base", "stats", "utils"), test_path = "tests/testthat" ) @@ -105,8 +109,8 @@ test_that( testthat::expect_silent( assertHE:::tabulate_functions_in_folder_with_tests( - path = path, - path_exclude = "tests/testthat", + path = testthat::test_path("example_project"), + path_exclude = NULL, packages_to_exclude = NULL, test_path = "tests/testthat" ) @@ -115,16 +119,16 @@ test_that( df_tests <- assertHE:::tabulate_functions_in_folder_with_tests( - path = path, - path_exclude = "tests/testthat", + path = testthat::test_path("example_project"), + path_exclude = NULL, packages_to_exclude = c("base", "stats", "utils"), test_path = "tests/testthat" ) df_tests2 <- assertHE:::tabulate_functions_in_folder_with_tests( - path = path, - path_exclude = "tests/testthat", + path = testthat::test_path("example_project"), + path_exclude = NULL, packages_to_exclude = NULL, test_path = "tests/testthat" )