Skip to content

Commit

Permalink
Revert change
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Dec 1, 2023
1 parent 909a4a8 commit f05759a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
13 changes: 0 additions & 13 deletions tests/testthat/_snaps/xml_write.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# write_xml errors for incorrect directory and with invalid inputs

Code
x <- read_xml("<x/>")
filename <- "does_not_exist/test.xml"
write_xml(x, filename)
Condition
Error in `path_to_connection()`:
! 'does_not_exist' does not exist in current working directory ('C:/Users/RoyO/Documents/rrr-forks/xml2/tests/testthat').
Code
write_xml(x, c("test.xml", "foo"))
Condition
Expand All @@ -15,12 +8,6 @@

# write_xml works with nodeset input and connections

Code
filename <- "../test.xml.gz"
write_xml(y, filename, options = "no_declaration")
Condition
Error in `write_xml()`:
! Can only save length 1 node sets
Code
write_xml(y[1], c(filename, "foo"))
Condition
Expand Down
15 changes: 9 additions & 6 deletions tests/testthat/test-xml_write.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
test_that("write_xml errors for incorrect directory and with invalid inputs", {
x <- read_xml("<x/>")
filename <- "does_not_exist/test.xml"
expect_error(write_xml(x, filename), "'does_not_exist' does not exist in current working directory")

expect_snapshot(error = TRUE, {
x <- read_xml("<x/>")
filename <- "does_not_exist/test.xml"
write_xml(x, filename)
write_xml(x, c("test.xml", "foo"))
})
})
Expand Down Expand Up @@ -68,11 +69,13 @@ test_that("write_xml works with nodeset input and connections", {
x <- read_xml("<x><y/><y/></x>")
y <- xml_find_all(x, "//y")


filename <- "../test.xml.gz"
expect_error(
write_xml(y, filename, options = "no_declaration"),
"Can only save length 1 node sets"
)

expect_snapshot(error = TRUE, {
filename <- "../test.xml.gz"
write_xml(y, filename, options = "no_declaration")
write_xml(y[1], c(filename, "foo"))
})

Expand Down

0 comments on commit f05759a

Please sign in to comment.