tests/testthat/test-zzz.R

test_that(".onLoad sets default options correctly", {
  # Ensure the option is NOT set initially
  prev_option <- getOption("gtexr.verbose", NULL)
  if (!is.null(prev_option)) options(gtexr.verbose = NULL)

  # Simulate package loading
  gtexr:::.onLoad(libname = NULL, pkgname = "gtexr")

  # Check that the option is set
  expect_true(getOption("gtexr.verbose"))

  # Restore previous state
  options(gtexr.verbose = prev_option)
})

test_that(".onLoad does not overwrite existing options", {
  # Set a custom value
  options(gtexr.verbose = FALSE)

  # Simulate package loading
  gtexr:::.onLoad(libname = NULL, pkgname = "gtexr")

  # Ensure the value remains unchanged
  expect_false(getOption("gtexr.verbose"))

  # Cleanup
  options(gtexr.verbose = NULL)
})

Try the gtexr package in your browser

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

gtexr documentation built on June 8, 2025, 10:26 a.m.