Skip to content

Commit

Permalink
add test-12 offlineMode
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliot McIntire committed Aug 2, 2024
1 parent bf2beaa commit d2eeec1
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/testthat/test-12offlineMode_testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
test_that("test12 Require.offlineMode", {

# skip_if(getOption("Require.usePak"), message = "Not an option on usePak = TRUE")
setupInitial <- setupTest()

isDev <- getOption("Require.isDev")
isDevAndInteractive <- getOption("Require.isDevAndInteractive")
fpcs <- c("fpCompare", "PredictiveEcology/fpCompare")
cachePurge()
for (fpc in fpcs) {
fpcPkgName <- extractPkgName(fpc)
cacheClearPackages(fpcPkgName, ask = FALSE)
Install(fpc)
mess <- capture_messages(remove.packages(fpcPkgName))
options(Require.offlineMode = TRUE)
Install(fpc)
expect_true(base::require(fpcPkgName, quietly = TRUE, character.only = TRUE))
detach(name = paste0("package:", fpcPkgName), unload = TRUE, character.only = TRUE)
# expect_match(basename(find.package(fpcPkgName)), fpcPkgName)
mess <- capture_messages(remove.packages(fpcPkgName))
expect_false(base::require(fpcPkgName, quietly = TRUE, character.only = TRUE))
cacheClearPackages(fpcPkgName, ask = FALSE)
warns <- capture_warnings(Install(fpc))
expect_false(base::require(fpcPkgName, quietly = TRUE, character.only = TRUE))
expect_match(warns, .txtCouldNotBeInstalled)
options(Require.offlineMode = FALSE)
# cacheClearPackages(extractPkgName(fpc), ask = FALSE)
Install(fpc)
expect_true(base::require(fpcPkgName, quietly = TRUE, character.only = TRUE))
detach(name = paste0("package:", fpcPkgName), unload = TRUE, character.only = TRUE)
mess <- capture_messages(remove.packages(fpcPkgName))
Install(fpc)
expect_true(base::require(fpcPkgName, quietly = TRUE, character.only = TRUE))
detach(name = paste0("package:", fpcPkgName), unload = TRUE, character.only = TRUE)
mess <- capture_messages(remove.packages(fpcPkgName))

}

})

0 comments on commit d2eeec1

Please sign in to comment.