Skip to content

Commit

Permalink
Scrub a filepath from this snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Mar 10, 2023
1 parent e53d694 commit 41c8b80
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
100 changes: 100 additions & 0 deletions tests/testthat/_snaps/read-excel.new.md
@@ -0,0 +1,100 @@
# xlsx is not read as xls and vice versa

Code
read_xls(test_sheet("iris-excel-xlsx.xlsx"))
Error <simpleError>
filepath: /Users/jenny/rrr/readxl/tests/testthat/sheets/iris-excel-xlsx.xlsx
libxls error: Unable to open file

---

Code
read_xlsx(test_sheet("iris-excel-xls.xls"))
Error <simpleError>
zip file 'VOLATILE_FILEPATH' cannot be opened

# non-existent file throws error

Code
read_excel("foo")
Error <simpleError>
`path` does not exist: 'foo'

# read_excel catches invalid guess_max

Code
read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = NA)
Error <simpleError>
`guess_max` must be a positive integer

---

Code
read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = -1)
Error <simpleError>
`guess_max` must be a positive integer

---

Code
out <- read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = Inf)
Warning <simpleWarning>
`guess_max` is a very large value, setting to `21474836` to avoid exhausting memory

---

Code
read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = NULL)
Error <simpleError>
`guess_max` must be a positive integer

---

Code
read_excel(test_sheet("iris-excel-xlsx.xlsx"), guess_max = 1:2)
Error <simpleError>
`guess_max` must be a positive integer

# read_excel catches invalid n_max

Code
read_excel(test_sheet("iris-excel-xlsx.xlsx"), n_max = NA)
Error <simpleError>
`n_max` must be a positive integer

---

Code
read_excel(test_sheet("iris-excel-xlsx.xlsx"), n_max = -1)
Error <simpleError>
`n_max` must be a positive integer

---

Code
read_excel(test_sheet("iris-excel-xlsx.xlsx"), n_max = NULL)
Error <simpleError>
`n_max` must be a positive integer

---

Code
read_excel(test_sheet("iris-excel-xlsx.xlsx"), n_max = 1:2)
Error <simpleError>
`n_max` must be a positive integer

# sheet must be integer or string

Code
read_excel(test_sheet("mtcars.xls"), sheet = TRUE)
Error <simpleError>
`sheet` must be either an integer or a string.

# trim_ws must be a logical

Code
read_excel(test_sheet("mtcars.xls"), trim_ws = "yes")
Error <simpleError>
`trim_ws` must be either TRUE or FALSE

7 changes: 6 additions & 1 deletion tests/testthat/test-read-excel.R
Expand Up @@ -16,13 +16,18 @@ test_that("can read files with and without extension [xls]", {
})

test_that("xlsx is not read as xls and vice versa", {
scrubfun <- function(x) {
sub("'.*iris-excel-xlsx?.xlsx?'", "'VOLATILE_FILEPATH'", x)
}
expect_snapshot(
error = TRUE,
read_xls(test_sheet("iris-excel-xlsx.xlsx"))
read_xls(test_sheet("iris-excel-xlsx.xlsx")),
transform = scrubfun
)
expect_snapshot(
error = TRUE,
read_xlsx(test_sheet("iris-excel-xls.xls")),
transform = scrubfun
)
})

Expand Down

0 comments on commit 41c8b80

Please sign in to comment.