tests/testthat/test-utils_condition.R

tar_test("tar_throw_prelocal()", {
  expect_error(
    tar_throw_prelocal("x"),
    class = "tar_condition_prelocal"
  )
})

tar_test("tar_throw_run() forwards custom error condition", {
  out <- tryCatch(
    tar_throw_run("x", class = c("my_class_1", "my_class_2")),
    error = function(condition) class(condition)
  )
  expect_true("my_class_1" %in% out)
  expect_true("my_class_2" %in% out)
})

tar_test("special case in safe_condition_class()", {
  class <- c("rlib_error_package_not_found", "another")
  expect_equal(safe_condition_class(class), "another")
})

Try the targets package in your browser

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

targets documentation built on June 8, 2025, 10:24 a.m.