Skip to content

Commit

Permalink
Use inline test
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed May 21, 2024
1 parent 0054a5b commit dfed20d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
# read_meta() errors gracefully if _pkgdown.yml failed to parse

Code
as_pkgdown(test_path("assets/bad-yaml"))
as_pkgdown(pkg$src_path)
Condition
Error in `as_pkgdown()`:
! Could not parse config file at 'assets/bad-yaml/_pkgdown.yml'.
! Could not parse config file at '<src>/_pkgdown.yml'.
Caused by error in `yaml.load()`:
! Scanner error: mapping values are not allowed in this context at line 2, column 8

3 changes: 0 additions & 3 deletions tests/testthat/assets/bad-yaml/DESCRIPTION

This file was deleted.

6 changes: 0 additions & 6 deletions tests/testthat/assets/bad-yaml/_pkgdown.yml

This file was deleted.

8 changes: 7 additions & 1 deletion tests/testthat/test-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ test_that("titles don't get autolinked code", {
})

test_that("read_meta() errors gracefully if _pkgdown.yml failed to parse", {
pkg <- local_pkgdown_site()
write_lines(path = path(pkg$src_path, "_pkgdown.yml"), c(
"url: https://pkgdown.r-lib.org",
" title: Build websites for R packages"
))
expect_snapshot(
as_pkgdown(pkg$src_path),
error = TRUE,
as_pkgdown(test_path("assets/bad-yaml"))
transform = function(x) gsub(pkg$src_path, "<src>", x, fixed = TRUE)
)
})

0 comments on commit dfed20d

Please sign in to comment.