Skip to content

Commit

Permalink
test for bad-folder-id
Browse files Browse the repository at this point in the history
ref #549
  • Loading branch information
wibeasley committed Nov 3, 2024
1 parent 7efb0ce commit 5539433
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
structure(list(), class = c("tbl_df", "tbl", "data.frame"), row.names = integer(0), names = character(0))
34 changes: 34 additions & 0 deletions tests/testthat/test-file-repo-list-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,40 @@ test_that("first-subdirectory", {
expect_true(returned_object$elapsed_seconds>0, "The `elapsed_seconds` should be a positive number.")
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
})
test_that("bad-folder-id", {
testthat::skip_on_cran()
expected_message <- "ERROR: The File Repository folder folder_id=99 does not exist or else you do not have permission to that folder because it is DAG-restricted or Role-restricted."

path_expected <- "test-data/specific-redcapr/file-repo-list-oneshot/bad-folder-id.R"

suppressMessages({
expect_message(
returned_object <-
redcap_file_repo_list_oneshot(
redcap_uri = credential$redcap_uri,
token = credential$token,
folder_id = 99
),
expected_message
)
})

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

#Test the values of the returned object.
if (credential$redcap_uri == "https://redcap-dev-2.ouhsc.edu/redcap/api/") {
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(nrow(returned_object$data), expected=0L)

expect_false(returned_object$success)
expect_equal(returned_object$status_code, expected=400L)
expect_match(returned_object$outcome_message, regexp=expected_message, perl=TRUE)
expect_true(returned_object$elapsed_seconds>0, "The `elapsed_seconds` should be a positive number.")
expect_equal(returned_object$raw_text, expected=expected_message, ignore_attr = TRUE) # dput(returned_object$raw_text)
})
test_that("download w/ bad token -Error", {
testthat::skip_on_cran()

Expand Down

0 comments on commit 5539433

Please sign in to comment.