tests/testthat/test-tar_knitr_deps.R

targets::tar_test("tar_knitr_deps()", {
  skip_rmarkdown()
  lines1 <- c(
    "---",
    "title: report",
    "output_format: html_document",
    "---",
    "",
    "```{r}",
    "tar_load(data1)",
    "tar_read(data2)",
    "```"
  )
  lines2 <- c(
    "---",
    "title: report",
    "output_format: html_document",
    "---",
    "",
    "```{r}",
    "tar_load(data2)",
    "tar_read(data3)",
    "```"
  )
  report1 <- tempfile()
  report2 <- tempfile()
  writeLines(lines1, report1)
  writeLines(lines2, report2)
  out <- tar_knitr_deps(c(report1, report2))
  exp <- c("data1", "data2", "data3")
  expect_equal(sort(out), sort(exp))
})

Try the tarchetypes package in your browser

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

tarchetypes documentation built on Oct. 4, 2023, 5:08 p.m.