File: test-template.R

package info (click to toggle)
r-cran-usethis 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,228 kB
  • sloc: sh: 26; makefile: 17; cpp: 6; ansic: 3
file content (21 lines) | stat: -rw-r--r-- 831 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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$")
})