Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
* test-get_affiliation
* test-acronyms

The mix of warning and return value was causing a warning
in the test rather than a pass status. Also, latex was not installed
so the acronyms could not be tested.
Codecoverage needs all tests to be passing.
  • Loading branch information
kellijohnson-NOAA committed May 17, 2023
1 parent 117a78f commit 85cf12c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
12 changes: 12 additions & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Setup for the unit tests

# Check for lualatex
if (!requireNamespace("tinytex", quietly = TRUE)) {
install.packages("tinytex")
}
if (any(tinytex:::which_bin(c("tlmgr", "pdftex", "xetex", "luatex")) == "")) {
tinytex::install_tinytex(bundle = "TinyTex")
}
if (!tinytex::check_installed("glossaries")) {
tinytex::tlmgr_install("glossaries")
}
5 changes: 3 additions & 2 deletions tests/testthat/test-acronyms.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ test_that("Acronyms compile with hyperlink", {
on.exit(setwd(old_wd))
on.exit(unlink(dir_build, recursive = TRUE), add = TRUE)
setwd(dir_build)
end <- system(
paste("lualatex", basename(file_doc))
end <- system2(
command = "lualatex",
args = paste(basename(file_doc))
)
expect_equal(end, 0)
})
7 changes: 6 additions & 1 deletion tests/testthat/test-get_affiliation.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
test_that("Unknown author returns NA", {
expect_true(is.na(get_affiliation("Kelli Johnson")))
expect_warning(
is.na(get_affiliation("Kelli Johnson"))
)
expect_true(
suppressWarnings(is.na(get_affiliation("Kelli Johnson")))
)
})
2 changes: 1 addition & 1 deletion tests/testthat/test-session.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("session_test is successful", {
test <- session_test()
test <- suppressWarnings(session_test())
expect_false(
inherits(test, "error")
)
Expand Down

0 comments on commit 85cf12c

Please sign in to comment.