Skip to content

Commit

Permalink
create manifest and testing helpers
Browse files Browse the repository at this point in the history
ref #40
  • Loading branch information
wibeasley committed Jan 3, 2020
1 parent 664caf2 commit 63d1ce2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DESCRIPTION
Expand Up @@ -26,6 +26,8 @@ Authors@R: c(
Imports:
httr,
jsonlite,
magrittr,
readr,
stats,
utils,
xml2
Expand Down
4 changes: 4 additions & 0 deletions 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",
File renamed without changes.
43 changes: 43 additions & 0 deletions 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)
# }

0 comments on commit 63d1ce2

Please sign in to comment.