This repository was archived by the owner on Jun 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ bind_tweet_jsons <- function(data_path) {
2121 recursive = T ,
2222 include.dirs = T
2323 )
24+
25+ if (length(files )< 1 ){
26+ stop(" There are no files matching the pattern `data_` in the specified directory." )
27+ }
28+
2429 files <- paste(data_path , files , sep = " " )
2530
2631 pb = utils :: txtProgressBar(min = 0 ,
Original file line number Diff line number Diff line change 1+ context(" bind_tweet_jsons" )
2+
13
24empty_dir <- tempdir()
3- jsonlite :: write_json(jsonlite :: toJSON(mtcars ),
5+
6+ my_cars <- mtcars
7+ my_cars $ model <- rownames(my_cars )
8+
9+ jsonlite :: write_json(my_cars ,
410 path = file.path(empty_dir , " data_1.json" ))
5- jsonlite :: write_json(jsonlite :: toJSON( mtcars ) ,
11+ jsonlite :: write_json(my_cars ,
612 path = file.path(empty_dir , " data_2.json" ))
713
8- test_that(" Error on non-twitter json binding" , {
9- expect_error(bind_tweet_jsons(empty_dir ))
14+ test_that(" Expect sucess in binding two jsons" , {
15+ expect_equal(bind_tweet_jsons(empty_dir ),
16+ dplyr :: bind_rows(my_cars ,my_cars ))
1017})
18+
19+ unlink(empty_dir , recursive = TRUE )
20+ temp_dir <- tempdir()
21+
22+ test_that(" Error on finding no jsons to bind" , {
23+ expect_error(bind_tweet_jsons(temp_dir ))
24+ })
25+
You can’t perform that action at this time.
0 commit comments