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.
})
wlandau/targets documentation built on May 1, 2024, 7:27 p.m.