tests/testthat/test-template.R

test_that("can leave existing file unchanged, without an error", {
  create_local_package()
  desc_lines_before <- read_utf8(proj_path("DESCRIPTION"))
  expect_no_error(
    use_template("NEWS.md", "DESCRIPTION")
  )
  desc_lines_after <- read_utf8(proj_path("DESCRIPTION"))
  expect_identical(desc_lines_before, desc_lines_after)
})

# helpers -----------------------------------------------------------------

test_that("find_template errors if template missing", {
  expect_usethis_error(find_template("xxx"), "Could not find template")
})

test_that("find_template can find templates for tricky Rbuildignored files", {
  expect_match(find_template("codecov.yml"), "codecov\\.yml$")
  expect_match(find_template("cran-comments.md"), "cran-comments\\.md$")
  expect_match(find_template("template.Rproj"), "template\\.Rproj$")
})

Try the usethis package in your browser

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

usethis documentation built on July 9, 2023, 7:23 p.m.