Skip to content

Commit 8623c90

Browse files
committed
fixed some path issues in tests
1 parent 6cf6f3f commit 8623c90

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

tests/testthat/integration_tests/test_get_pkg_functions.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
context("get_package_functions")
22

33

4-
proj <- usethis::proj_get()
4+
proj <- rprojroot::find_package_root_file()
55

66
test_that('get_pkg_tested_functions_from_desc works', {
77
#* @testing get_pkg_tested_functions_from_desc
@@ -16,8 +16,9 @@ test_that('get_pkg_tested_functions_from_desc works', {
1616
get_pkg_tested_functions_from_desc()
1717
)
1818

19-
expect_identical(tres, tfuns[1:4])
19+
expect_identical(names(tres[sapply(tres, length) > 0]), tfuns[1:4])
20+
2021
usethis::proj_set(proj)
2122
})
2223

23-
usethis::proj_set(proj)
24+

tests/testthat/integration_tests/test_infrastructure.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
context("infrastructure-non cran tests")
22

3-
proj <- usethis::proj_get()
3+
proj <- rprojroot::find_package_root_file()
44

55
test_that("use_testdata creates testdata dir", {
66
#* @testing has_testdata
@@ -154,3 +154,4 @@ test_that("use_test_subdir works as expected", {
154154
expect_identical(package_state, list.files(".", recursive = TRUE))
155155
usethis::proj_set(proj)
156156
})
157+

tests/testthat/integration_tests/test_list_test_files.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
context("list_test_files")
22

3-
proj <- usethis::proj_get()
3+
proj <- rprojroot::find_package_root_file()
44

55
test_that("list_test_files works as expected", {
66
#* @testing list_test_files

tests/testthat/integration_tests/test_use_testdata.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
context("use_testdata")
22

3-
proj <- usethis::proj_get()
3+
proj <- rprojroot::find_package_root_file()
44

55

66
test_that("saving and loading testdata works", {
77
#* @testing read_testdata
88
#* @testing use_testdata
99

10+
# Check for clean state
1011
package_state <- list.files(".", recursive = TRUE)
1112
tpkg <- file.path(rprojroot::find_testthat_root_file("testdata", "test_pkg"))
1213
usethis::proj_set(tpkg)
1314
efile <- file.path(tpkg, "tests", "testthat", "testdata", "iris.rds")
1415

1516

1617
# Test saving and loading
17-
expect_message(use_testdata(iris), "Saving to")
18+
expect_output(expect_message(use_testdata(iris), "Saving to"))
1819
expect_true(file.exists(efile))
1920
tdat <- read_testdata("iris.rds")
2021
expect_identical(iris, tdat)
21-
unlink(efile)
22+
23+
unlink(
24+
file.path(tpkg, "tests/testthat/testdata"),
25+
recursive = TRUE
26+
)
2227

2328
# Check if tests did not modify package
2429
usethis::proj_set(proj)

tests/testthat/integration_tests/test_use_testignore.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
context("use_testignore")
22

3-
proj <- usethis::proj_get()
3+
proj <- rprojroot::find_package_root_file()
44

55
test_that("use_testignore works as expected", {
66
fs <- list.files(".")

0 commit comments

Comments
 (0)