tests/testthat/test_inet.R

## test_that("inet_readChar() fails on timeout", {
##     ## readability
##     mock <- testthat::with_mock
##     envvar <- withr::with_envvar
##     readMock <- function(...) stop("mock error")

##     expect_false(getOption("BIOCMANAGER_CRANCHECK_BEHAVIOR"))
##     expect_false(BiocManager:::.is_CRAN_check())

##     cat("BIOCMANAGER_CRANCHECK_BEHAVIOR: ", getOption("BIOCMANAGER_CRANCHECK_BEHAVIOR"), "\n")
##     cat(paste(names(Sys.getenv()), collapse="\n"), "\n")
##     if (!any(grepl("_CRAN_", names(Sys.getenv()))))
##         ## expect error not under --as-cran
##         expect_error(mock(readChar = readMock, available()), "mock error")

##     ## under CRAN (--as-cran) expect to find environmental variable(s)
##     ## "*_CRAN_*" and to generate message instead of error
##     expect_message({
##         envvar(
##             c(FAUX_CRAN_VAR = "any"),
##             mock(readChar = readMock, available())
##         )
##     }, "mock error")

## })

Try the BiocManager package in your browser

Any scripts or data that you put into this service are public.

BiocManager documentation built on Sept. 11, 2024, 8:07 p.m.