Skip to content

Commit

Permalink
Adjust test + add snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Dec 1, 2023
1 parent a85effe commit 697cb47
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 10 additions & 0 deletions tests/testthat/_snaps/xml_parse.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

`x` must be a single string, not an empty character vector.

# parse_options errors when given an invalid option

Code
read_html(test_path("lego.html.bz2"), options = "INVALID")
Condition
Error in `read_html()`:
x `options` "INVALID" is not a valid option.
i Valid options are one of "RECOVER", "NOENT", "DTDLOAD", "DTDATTR", "DTDVALID", "NOERROR", "NOWARNING", "PEDANTIC", "NOBLANKS", "SAX1", "XINCLUDE", "NONET", "NODICT", "NSCLEAN", "NOCDATA", "NOXINCNODE", "COMPACT", "OLD10", ..., "IGNORE_ENC", or "BIG_LINES".
i See read_html (`?xml2::read_html()`) for all options.

# read_xml and read_html fail with > 1 input

`x` must be a single string, not a character vector.
Expand Down
7 changes: 3 additions & 4 deletions tests/testthat/test-xml_parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ test_that("read_html correctly parses malformed document", {
test_that("parse_options errors when given an invalid option", {
expect_error(
parse_options("INVALID", xml_parse_options()),
"`options` 'INVALID' is not a valid option"
'`options` "INVALID" is not a valid option'
)

expect_error(
read_html(test_path("lego.html.bz2"), options = "INVALID"),
"`options` 'INVALID' is not a valid option"
expect_snapshot(error = TRUE,
read_html(test_path("lego.html.bz2"), options = "INVALID")
)

# Empty inputs returned as 0
Expand Down

0 comments on commit 697cb47

Please sign in to comment.