tests/testthat/test-utils_ask.R

tar_test("tar_ask_env()", {
  Sys.setenv(TAR_ASK = "")
  expect_null(tar_ask_env())
  Sys.setenv(TAR_ASK = "true")
  expect_true(tar_ask_env())
  Sys.setenv(TAR_ASK = "false")
  expect_false(tar_ask_env())
})

tar_test("tar_should_overwrite", {
  tmp <- tempfile()
  expect_true(tar_should_overwrite(path = tmp, ask = TRUE))
  expect_true(tar_should_overwrite(path = tmp, ask = FALSE))
  file.create(tmp)
  expect_true(tar_should_overwrite(path = tmp, ask = FALSE))
  # More testing is in tests/interactive/test-tar_script.R # nolint.
})

Try the targets package in your browser

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

targets documentation built on Oct. 12, 2023, 5:07 p.m.