Skip to content

Commit

Permalink
Fix #435 (#441)
Browse files Browse the repository at this point in the history
* Fix #435

* Integration test
  • Loading branch information
chainsawriot authored Jul 11, 2024
1 parent 4071bec commit ff585e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ escape_xml <- function(x, replacement = c("&amp;", "&quot;", "&lt;", "&gt;", "&a
if (isFALSE(length(file) == 1) && single_only) {
stop("Invalid `file` argument: `file` must be single", call. = FALSE)
}
if (any(is.na(file))) {
stop("Invalid `file` argument: `file` must not be NA", call. = FALSE)
}
invisible(NULL)
}

Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test_check_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ test_that(".check_file", {
expect_error(.check_file(data))
expect_error(.check_file(iris))
expect_error(.check_file(c("a.csv", "b.csv")))
expect_error(.check_file(NA))
expect_error(.check_file(NA_character_))
expect_error(.check_file(c(NA, "a.csv")))
expect_error(.check_file(c(NA_character_, "a.csv")))
expect_error(.check_file("a.csv"), NA)
expect_error(.check_file(), NA)
## single_only FALSE
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test_compress.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,11 @@ test_that("Relative path #438", {
expect_true(file.exists("arch/archive.zip"))
})
})

test_that("Integration test #435", {
## filter out all NA cases so that #437 works
withr::with_tempfile("iris_path", fileext = "csv.zip", code = {
expect_error(rio::export(iris, NA), "must be character") ## strange to be honest
expect_error(rio::export(iris, NA_character_), "must not be NA")
})
})

0 comments on commit ff585e2

Please sign in to comment.