Skip to content

Commit

Permalink
Add warning handling
Browse files Browse the repository at this point in the history
warning only emitted if package loaded with pkgload, which does not
happen with R CMD CHECK
  • Loading branch information
AlexAxthelm committed Mar 25, 2024
1 parent eb69f3a commit f6a54f2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/testthat/test-get_package_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@ logger::log_appender(logger::appender_stdout)
logger::log_threshold(logger::FATAL)
logger::log_layout(logger::layout_simple)

expect_warning_if_not_cran <- function(object, regexp) {
on_cran <- (
!interactive() &&
!isTRUE(as.logical(Sys.getenv("NOT_CRAN", "false")))
)
if (on_cran) {
object
} else {
testthat::expect_warning(object = object, regexp = regexp)
}
}

test_that("get_package_info outputs correct structure for defaults", {
testthat::expect_warning(
expect_warning_if_not_cran(
object = {
package_info <- get_package_info()
expect_named(
Expand Down

0 comments on commit f6a54f2

Please sign in to comment.