File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
integration-tests/testthat Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 18
18
# ' @export
19
19
load_responses_all <- function (params , contingency_run = FALSE ) {
20
20
msg_plain(paste0(" Loading " , length(params $ input ), " CSVs" ))
21
-
21
+
22
22
map_fn <- if (params $ parallel ) { mclapply } else { lapply }
23
23
input_data <- map_fn(seq_along(params $ input ), function (i ) {
24
24
load_response_one(params $ input [i ], params , contingency_run )
25
25
})
26
26
27
27
msg_plain(paste0(" Finished loading CSVs" ))
28
+
29
+ which_errors <- unlist(lapply(input_data , inherits , " try-error" ))
30
+ if (any( which_errors )) {
31
+ errored_filenames <- paste(params $ input [which_errors ], collapse = " , " )
32
+ stop(
33
+ " ingestion and field creation failed for at least one of input data file(s) " ,
34
+ errored_filenames ,
35
+ " with error(s)\n " ,
36
+ unique(input_data [which_errors ])
37
+ )
38
+ }
39
+
28
40
input_data <- bind_rows(input_data )
29
41
msg_plain(paste0(" Finished combining CSVs" ))
30
42
return (input_data )
Original file line number Diff line number Diff line change @@ -385,3 +385,10 @@ test_that("testing national aggregation", {
385
385
}
386
386
387
387
})
388
+
389
+ test_that(" testing load_responses behavior for missing input" , {
390
+ params <- relativize_params(read_params(test_path(" params-test.json" )))
391
+ params $ input <- c(params $ input , " file-does-not-exist.csv" )
392
+ params $ parallel <- TRUE
393
+ expect_error(load_responses_all(params ), regexp = " ingestion and field creation failed" )
394
+ })
You can’t perform that action at this time.
0 commit comments