tests/testthat/test-tar_helper_raw.R

tar_test("tar_helper_raw() with one line", {
  path <- tempfile()
  tar_helper_raw(path, quote(x <- 1))
  expect_equal(readLines(path), "x <- 1")
})

tar_test("tar_helper_raw() with nonexistent parent dir", {
  path <- file.path(tempfile(), "x", "y", "z")
  tar_helper_raw(path, quote(x <- 1))
  expect_equal(readLines(path), "x <- 1")
})

tar_test("tar_helper_raw() with more than one line", {
  path <- tempfile()
  expr <- quote({
    x <- 1
    y <- 2
  })
  tar_helper_raw(path, expr)
  expect_equal(readLines(path), c("x <- 1", "y <- 2"))
})

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.