2023-01-16 09:49:17 +01:00
|
|
|
## "Primary table name processing"
|
2019-07-08 18:19:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Global variables -------------------------------------------------------
|
2023-04-13 10:57:04 +02:00
|
|
|
metadata <-
|
|
|
|
jsonlite::fromJSON(get_data_location("ExampleProject_metadata.json"))
|
2023-01-16 09:49:17 +01:00
|
|
|
|
2023-04-13 10:57:04 +02:00
|
|
|
records <-
|
|
|
|
jsonlite::fromJSON(get_data_location("ExampleProject_records.json"))
|
2019-07-08 18:19:33 +02:00
|
|
|
|
|
|
|
ref_hash <- "2c8b6531597182af1248f92124161e0c"
|
|
|
|
|
|
|
|
# Tests -------------------------------------------------------------------
|
|
|
|
test_that("Will not use a repeating instrument name for primary table", {
|
2023-04-13 10:57:04 +02:00
|
|
|
redcap_output_json1 <-
|
|
|
|
expect_warning(REDCap_split(records, metadata, "sale"),
|
|
|
|
"primary table")
|
2019-07-08 18:19:33 +02:00
|
|
|
|
|
|
|
expect_known_hash(redcap_output_json1, ref_hash)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
test_that("Names are set correctly and output is identical", {
|
|
|
|
redcap_output_json2 <- REDCap_split(records, metadata, "main")
|
|
|
|
|
|
|
|
|
|
|
|
expect_identical(names(redcap_output_json2), c("main", "sale"))
|
|
|
|
expect_known_hash(setNames(redcap_output_json2, c("", "sale")), ref_hash)
|
|
|
|
|
|
|
|
})
|