tests/testthat/test-tar_name.R

tar_test("tar_name() outside a pipeline", {
  expect_equal(tar_name(), "target")
  expect_equal(tar_name(default = "custom"), "custom")
})

tar_test("tar_name() inside a pipeline", {
  x <- target_init("x", quote(targets::tar_name()))
  local_init(pipeline_init(list(x)))$run()
  expect_equal(target_read_value(x)$object, "x")
})

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.