Skip to content

Commit

Permalink
record field in logs
Browse files Browse the repository at this point in the history
close #478
  • Loading branch information
wibeasley committed Apr 21, 2023
1 parent 3720297 commit ac9dfba
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
17 changes: 16 additions & 1 deletion inst/test-data/specific-redcapr/log-read/2020-08-10.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,19 @@ structure(list(timestamp = structure(c(1597087500, 1597087500,
"export_format: CSV, rawOrLabel: raw", "Download data dictionary (API)",
"export_format: CSV, rawOrLabel: raw", "export_format: CSV, rawOrLabel: raw",
"Download data dictionary (API)", "Export REDCap version (API)",
"Export project information (API)")), row.names = c(NA, -96L), class = "data.frame")
"Export project information (API)"), record = c(NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA,
-96L), spec = structure(list(cols = list(timestamp = structure(list(
format = ""), class = c("collector_datetime", "collector"
)), username = structure(list(), class = c("collector_character",
"collector")), action = structure(list(), class = c("collector_character",
"collector")), details = structure(list(), class = c("collector_character",
"collector")), record = structure(list(), class = c("collector_logical",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
13 changes: 11 additions & 2 deletions inst/test-data/specific-redcapr/log-read/2021-07-11-record3-user.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,14 @@ structure(list(timestamp = structure(c(1626044880, 1626044880,
"Download file (API)", "Download file (API)", "Download file (API)",
"Download file (API)", "Download file (API)", "Download file (API)",
"Download file (API)", "Download file (API)", "Download file (API)",
"Download file (API)", "Download file (API)")), row.names = c(NA,
-12L), class = "data.frame")
"Download file (API)", "Download file (API)"), record = c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA,
-12L), spec = structure(list(cols = list(timestamp = structure(list(
format = ""), class = c("collector_datetime", "collector"
)), username = structure(list(), class = c("collector_character",
"collector")), action = structure(list(), class = c("collector_character",
"collector")), details = structure(list(), class = c("collector_character",
"collector")), record = structure(list(), class = c("collector_logical",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
12 changes: 6 additions & 6 deletions tests/testthat/test-log-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ library(testthat)
credential <- retrieve_credential_testing()
update_expectation <- FALSE

path_expected_2020_08 <- "test-data/specific-redcapr/log-read/2020-08-10.R"

test_that("smoke test", {
testthat::skip_on_cran()
expect_message({
Expand All @@ -18,7 +20,6 @@ test_that("smoke test", {

test_that("2020-08-10", {
testthat::skip_on_cran()
path_expected <- "test-data/specific-redcapr/log-read/2020-08-10.R"
expected_outcome_message <- "\\d+ rows were read from REDCap in \\d+(\\.\\d+\\W|\\W)seconds\\."

returned_object <-
Expand All @@ -30,8 +31,8 @@ test_that("2020-08-10", {
verbose = FALSE
)

if (update_expectation) save_expected(returned_object$data, path_expected)
expected_data_frame <- retrieve_expected(path_expected)
if (update_expectation) save_expected(returned_object$data, path_expected_2020_08)
expected_data_frame <- retrieve_expected(path_expected_2020_08)

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
Expand All @@ -44,7 +45,6 @@ test_that("2020-08-10", {

test_that("2020-08-10-api-export", {
testthat::skip_on_cran()
path_expected <- "test-data/specific-redcapr/log-read/2020-08-10.R"
expected_outcome_message <- "\\d+ rows were read from REDCap in \\d+(\\.\\d+\\W|\\W)seconds\\."

returned_object <-
Expand All @@ -56,8 +56,8 @@ test_that("2020-08-10-api-export", {
verbose = FALSE
)

if (update_expectation) save_expected(returned_object$data, path_expected)
expected_data_frame <- retrieve_expected(path_expected)
if (update_expectation) save_expected(returned_object$data, path_expected_2020_08)
expected_data_frame <- retrieve_expected(path_expected_2020_08)

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
Expand Down

0 comments on commit ac9dfba

Please sign in to comment.