diff --git a/DESCRIPTION b/DESCRIPTION index f967b2c..72d8210 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,6 +26,8 @@ Authors@R: c( Imports: httr, jsonlite, + magrittr, + readr, stats, utils, xml2 diff --git a/inst/manifest-testing.csv b/inst/manifest-testing.csv new file mode 100644 index 0000000..eb20d64 --- /dev/null +++ b/inst/manifest-testing.csv @@ -0,0 +1,4 @@ +"subdataverse","file_name","size_bytes","location_expected","compare_cells","md5" +"rosters","roster-bulls-1996.tab",4200,"rawgithub.com/qqqq","T", +"open-source-at-harvard","data/2019-05-25.tsv",2300,,"T", +"open-source-at-harvard","run.sh",1023,,"F", diff --git a/inst/roster-bulls-1996.csv b/inst/rosters/roster-bulls-1996.csv similarity index 100% rename from inst/roster-bulls-1996.csv rename to inst/rosters/roster-bulls-1996.csv diff --git a/tests/testthat/utils-manifest.R b/tests/testthat/utils-manifest.R new file mode 100644 index 0000000..2943ad3 --- /dev/null +++ b/tests/testthat/utils-manifest.R @@ -0,0 +1,43 @@ +retrieve_manifest <- function ( ) { + # Refresh col_types with: OuhscMunge::readr_spec_aligned(path) + path <- system.file("manifest-testing.csv", package = "dataverse") + col_types <- readr::cols_only( + `subdataverse` = readr::col_character(), + `file_name` = readr::col_character(), + `size_bytes` = readr::col_integer(), + `location_expected` = readr::col_character(), + `compare_cells` = readr::col_logical(), + `md5` = readr::col_character() + ) + d <- readr::read_csv(path, col_types = col_types) + + d +} +# retrieve_manifest() +# checkmate::assert_fi + +retrieve_file_expected <- function (subdataverse, file_name) { + path <- + file.path(subdataverse, file_name) %>% + system.file(package = "dataverse") + + if (!file.exists(path)) { + stop( + "The testing file `", + file_name, + "` in the (sub)datavserse `", + subdataverse, + "` is not found. Please verify that the manifest is synced with the collection of test files. " + ) + } + + readr::read_file(path) +} +# retrieve_file_expected("rosters", "roster-bulls-1996.csv") + + +# compare_data_frame <- function (d_actual, d_expected) { +# +# # Compare cell contents +# testthat::expect_equal(d_actual, d_expected) +# }