Skip to content

Commit

Permalink
Update #26
Browse files Browse the repository at this point in the history
  • Loading branch information
mstackhouse committed Jan 2, 2024
1 parent ba60f32 commit cdaf383
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 23 deletions.
9 changes: 0 additions & 9 deletions R/read_dataset_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ read_dataset_json <- function(file) {
file_contents <- file
}

# Validate the input file against the schema
valid <- jsonvalidate::json_validate(file_contents, schema = schema_1_0_0, engine="ajv")

if (!valid) {
stop(paste0(c("Dataset JSON file is invalid per the JSON schema. ",
"Run datasetjson::validate_dataset_json(",substitute(file),") to see details")),
call.=FALSE)
}

# Read the file and convert to datasetjson object
ds_json <- jsonlite::fromJSON(file_contents)

Expand Down
9 changes: 0 additions & 9 deletions R/write_dataset_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ write_dataset_json <- function(x, file, pretty=FALSE) {
auto_unbox = TRUE,
pretty = pretty)

# Run the validator
valid <- jsonvalidate::json_validate(js, schema_1_0_0, engine="ajv")

if (!valid) {
stop(paste0(c("Dataset JSON file is invalid per the JSON schema. ",
"Run datasetjson::validate_dataset_json(",substitute(file),") to see details")),
call.=FALSE)
}

if (!missing(file)) {
# Write file to disk
cat(js, "\n", file = file)
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-read_dataset_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ test_that("read_dataset_json matches xpt", {
expect_equal(comp_attr[["label"]], comp_expected[["label"]])

# # ae
expect_error(read_dataset_json(test_path("testdata", "ae.json")), "Dataset JSON file is invalid")
expect_warning(e <- validate_dataset_json(test_path("testdata", "ae.json")), "File contains errors!")

# Simple crosscheck of the number of errors without verifying the whole dataframe
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-write_dataset_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ test_that("write_dataset_json matches the original json", {
expected$creationDateTime <- NULL

expect_equal(comp, expected)

# Error check
ds_json$asOfDateTime<- 1
expect_error(write_dataset_json(ds_json, json_location), "Dataset JSON file is invalid")
})

test_that("write_dataset_json errors are thrown properly", {
Expand Down

0 comments on commit cdaf383

Please sign in to comment.