diff --git a/tests/testthat/_snaps/config.md b/tests/testthat/_snaps/config.md index 2a5d61487..0374055e7 100644 --- a/tests/testthat/_snaps/config.md +++ b/tests/testthat/_snaps/config.md @@ -1,3 +1,21 @@ +# config_pluck_character generates informative error + + Code + config_pluck_character(pkg, "x") + Condition + Error: + ! x must be a character vector, not the number 1. + i Edit _pkgdown.yml to fix the problem. + +# config_pluck_string generates informative error + + Code + config_pluck_string(pkg, "x") + Condition + Error: + ! x must be a string, not the number 1. + i Edit _pkgdown.yml to fix the problem. + # config_check_list gives informative errors Code @@ -14,12 +32,3 @@ 1 missing component: "z". i Edit _pkgdown.yml to fix the problem. -# config_pluck_character generates informative error - - Code - config_pluck_character(pkg, "x") - Condition - Error: - ! x must be a character vector, not the number 1. - i Edit _pkgdown.yml to fix the problem. - diff --git a/tests/testthat/test-config.R b/tests/testthat/test-config.R index 453641c75..1e38b5961 100644 --- a/tests/testthat/test-config.R +++ b/tests/testthat/test-config.R @@ -1,8 +1,9 @@ test_that("config_pluck_character coerces empty values to character", { - pkg <- local_pkgdown_site(meta = list(x = NULL)) + pkg <- local_pkgdown_site(meta = list(x = NULL, y = list())) expect_equal(config_pluck_character(pkg, "x"), character()) expect_equal(config_pluck_character(pkg, "y"), character()) + expect_equal(config_pluck_character(pkg, "z"), character()) }) test_that("config_pluck_character generates informative error", { @@ -10,6 +11,11 @@ test_that("config_pluck_character generates informative error", { expect_snapshot(config_pluck_character(pkg, "x"), error = TRUE) }) +test_that("config_pluck_string generates informative error", { + pkg <- local_pkgdown_site(meta = list(x = 1)) + expect_snapshot(config_pluck_string(pkg, "x"), error = TRUE) +}) + # checkers -------------------------------------------------------------------- test_that("config_check_list() returns list if ok", {