tests/testthat/test-class_timestamp_positives.R

tar_test("run timestamp_positives reporter", {
  pipeline <- pipeline_init(list(target_init("x", quote(0))))
  for (index in seq_len(2L)) {
    local <- local_init(pipeline, reporter = "timestamp_positives")
    expect_message(local$run())
  }
})

tar_test("run timestamp_positives reporter with a error and saved workspace", {
  tar_option_set(workspace_on_error = TRUE)
  pipeline <- pipeline_init(
    list(
      target_init("x", quote(stop(123)))
    )
  )
  local <- local_init(pipeline, reporter = "timestamp_positives")
  expect_error(expect_message(local$run()), class = "tar_condition_run")
})

tar_test("run timestamp_positives reporter with a warning", {
  pipeline <- pipeline_init(list(target_init("x", quote(warning(123)))))
  local <- local_init(pipeline, reporter = "timestamp_positives")
  suppressWarnings(
    expect_warning(local$run(), class = "tar_condition_run")
  )
})

tar_test("run timestamp_positives reporter with a cancellation", {
  pipeline <- pipeline_init(
    list(target_init("x", quote(targets::tar_cancel())))
  )
  local <- local_init(pipeline, reporter = "timestamp_positives")
  expect_message(local$run())
})

tar_test("timestamp_positives reporter skipped", {
  tar_script(tar_target(x, 1))
  expect_message(
    tar_make(callr_function = NULL, reporter = "timestamp_positives")
  )
  expect_message(
    tar_make(callr_function = NULL, reporter = "timestamp_positives")
  )
})

tar_test("validate timestamp_positives reporter", {
  expect_silent(reporter_init("timestamp_positives")$validate())
})

Try the targets package in your browser

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

targets documentation built on Oct. 3, 2024, 1:11 a.m.