Skip to content

Commit ac9dfba

Browse files
committed
record field in logs
close #478
1 parent 3720297 commit ac9dfba

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

inst/test-data/specific-redcapr/log-read/2020-08-10.R

+16-1
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,19 @@ structure(list(timestamp = structure(c(1597087500, 1597087500,
112112
"export_format: CSV, rawOrLabel: raw", "Download data dictionary (API)",
113113
"export_format: CSV, rawOrLabel: raw", "export_format: CSV, rawOrLabel: raw",
114114
"Download data dictionary (API)", "Export REDCap version (API)",
115-
"Export project information (API)")), row.names = c(NA, -96L), class = "data.frame")
115+
"Export project information (API)"), record = c(NA, NA, NA, NA,
116+
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
117+
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
118+
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
119+
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
120+
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
121+
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA,
122+
-96L), spec = structure(list(cols = list(timestamp = structure(list(
123+
format = ""), class = c("collector_datetime", "collector"
124+
)), username = structure(list(), class = c("collector_character",
125+
"collector")), action = structure(list(), class = c("collector_character",
126+
"collector")), details = structure(list(), class = c("collector_character",
127+
"collector")), record = structure(list(), class = c("collector_logical",
128+
"collector"))), default = structure(list(), class = c("collector_guess",
129+
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
130+
"tbl_df", "tbl", "data.frame"))

inst/test-data/specific-redcapr/log-read/2021-07-11-record3-user.R

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,14 @@ structure(list(timestamp = structure(c(1626044880, 1626044880,
1111
"Download file (API)", "Download file (API)", "Download file (API)",
1212
"Download file (API)", "Download file (API)", "Download file (API)",
1313
"Download file (API)", "Download file (API)", "Download file (API)",
14-
"Download file (API)", "Download file (API)")), row.names = c(NA,
15-
-12L), class = "data.frame")
14+
"Download file (API)", "Download file (API)"), record = c(NA,
15+
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA,
16+
-12L), spec = structure(list(cols = list(timestamp = structure(list(
17+
format = ""), class = c("collector_datetime", "collector"
18+
)), username = structure(list(), class = c("collector_character",
19+
"collector")), action = structure(list(), class = c("collector_character",
20+
"collector")), details = structure(list(), class = c("collector_character",
21+
"collector")), record = structure(list(), class = c("collector_logical",
22+
"collector"))), default = structure(list(), class = c("collector_guess",
23+
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
24+
"tbl_df", "tbl", "data.frame"))

tests/testthat/test-log-read.R

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ library(testthat)
33
credential <- retrieve_credential_testing()
44
update_expectation <- FALSE
55

6+
path_expected_2020_08 <- "test-data/specific-redcapr/log-read/2020-08-10.R"
7+
68
test_that("smoke test", {
79
testthat::skip_on_cran()
810
expect_message({
@@ -18,7 +20,6 @@ test_that("smoke test", {
1820

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

2425
returned_object <-
@@ -30,8 +31,8 @@ test_that("2020-08-10", {
3031
verbose = FALSE
3132
)
3233

33-
if (update_expectation) save_expected(returned_object$data, path_expected)
34-
expected_data_frame <- retrieve_expected(path_expected)
34+
if (update_expectation) save_expected(returned_object$data, path_expected_2020_08)
35+
expected_data_frame <- retrieve_expected(path_expected_2020_08)
3536

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

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

5050
returned_object <-
@@ -56,8 +56,8 @@ test_that("2020-08-10-api-export", {
5656
verbose = FALSE
5757
)
5858

59-
if (update_expectation) save_expected(returned_object$data, path_expected)
60-
expected_data_frame <- retrieve_expected(path_expected)
59+
if (update_expectation) save_expected(returned_object$data, path_expected_2020_08)
60+
expected_data_frame <- retrieve_expected(path_expected_2020_08)
6161

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

0 commit comments

Comments
 (0)