Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
d-morrison committed Jan 8, 2025
1 parent a75f236 commit 6efd9fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/serocalculator_example.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#' serocalculator_example("example_pop_data.csv")
serocalculator_example <- function(file = NULL) {
if (is.null(file)) {
dir(system.file("extdata", package = "serocalculator"))
dir(fs::path_package("extdata", package = "serocalculator"))
} else {
system.file("extdata", file, package = "serocalculator", mustWork = TRUE)
fs::path_package("extdata", file, package = "serocalculator")
}
}
15 changes: 13 additions & 2 deletions tests/testthat/test-serocalculator_example.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
test_that("multiplication works", {
expect_equal(2 * 2, 4)
test_that("`serocalculator_example()` works", {

path1 = serocalculator_example("example_pop_data.csv")

Check warning on line 3 in tests/testthat/test-serocalculator_example.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-serocalculator_example.R,line=3,col=9,[assignment_linter] Use <-, not =, for assignment.
path2 = fs::path_package(package = "serocalculator",

Check warning on line 4 in tests/testthat/test-serocalculator_example.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-serocalculator_example.R,line=4,col=9,[assignment_linter] Use <-, not =, for assignment.
"extdata/example_pop_data.csv")
expect_equal(path1, path2)


files1 = serocalculator_example()

Check warning on line 9 in tests/testthat/test-serocalculator_example.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-serocalculator_example.R,line=9,col=10,[assignment_linter] Use <-, not =, for assignment.
files2 = "example_pop_data.csv"

Check warning on line 10 in tests/testthat/test-serocalculator_example.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-serocalculator_example.R,line=10,col=10,[assignment_linter] Use <-, not =, for assignment.

expect_equal(files1, files2)

})

0 comments on commit 6efd9fe

Please sign in to comment.