Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo committed Feb 4, 2024
1 parent 9d55f69 commit 7f168bc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/xlsx_cutter.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ xlsx_cutter <- function(

if (any(failed)) {
warning(
"parsing failed for ", sum(failed), " files:\n",
toString(data_files[failed])
"parsing failed for ", sum(failed), " files:\n - ",
paste(data_files[failed], collapse = "\n - "),
call. = FALSE
)
}

Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/_snaps/xlsx_cutter.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@
]
}

# failures don't stop loop

parsing failed for 2 files:
- nonexistent_file.xlsx
- nonexistent_file2.xlsx

13 changes: 13 additions & 0 deletions tests/testthat/test-xlsx_cutter.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ test_that("xlsx_cutter() works", {
)

})

test_that("failures don't stop loop", {

expect_snapshot_warning(
res <- xlsx_cutter( # nolintr: assignment_linter.
c("nonexistent_file.xlsx", "nonexistent_file2.xlsx", data_files),
template_file
)
)

expect_identical(nrow(res), length(data_files))

})

0 comments on commit 7f168bc

Please sign in to comment.