tests/testthat/test_luzlogr.R

# Testing onAttach, onLoad code

context("luzlogr")

test_that("onLoad sets options correctly", {

  options(luzlogr.close_on_error = TRUE)
  expect_silent(.onLoad())
  expect_true(getOption("luzlogr.close_on_error"))

  options(luzlogr.close_on_error = NULL)
  expect_silent(.onLoad())
  expect_false(getOption("luzlogr.close_on_error"))
})

test_that("onAttach sets error handler correctly", {

  options(luzlogr.close_on_error = FALSE)
  expect_silent(.onAttach())

  options(luzlogr.close_on_error = TRUE)
  oe <- getOption("error")
  options(error = NULL)
  expect_silent(.onAttach())
  expect_is(getOption("error"), "call")
})

Try the luzlogr package in your browser

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

luzlogr documentation built on May 29, 2024, 3:50 a.m.