Skip to content

Commit

Permalink
throw error if not successful
Browse files Browse the repository at this point in the history
ref #372
  • Loading branch information
wibeasley committed Nov 22, 2021
1 parent ace93f1 commit e77e839
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions R/redcap-delete.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ redcap_delete <- function(
"The REDCapR delete operation was not successful. The error message was:\n%s",
kernel$raw_text
)
stop(outcome_message)
}

if (verbose)
Expand Down
36 changes: 17 additions & 19 deletions tests/testthat/test-delete.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,21 @@ test_that("single-arm-four-records", {
expect_true(returned_object2$success)
})

test_that("no-delete-permissions", {
testthat::skip_on_cran()
skip_if_onlyread()
credential <- retrieve_credential_testing(213L) # Write-project, but no privileges for deleting records

records_to_delete <- 1

# test_that("single-arm-four-records", {
# testthat::skip_on_cran()
# skip_if_onlyread()
# credential <- retrieve_credential_testing(213L) # Write-project, but no privileges for deleting records
#
# records_to_delete <- 1
#
# expected_outcome_message <- "You do not have Delete Record privileges"
# expect_error(
# returned_object1 <-
# redcap_delete(
# redcap_uri = credential$redcap_uri,
# token = credential$token,
# records_to_delete = records_to_delete
# )#,
# # regexp = expected_outcome_message
# )
#
# })
expected_outcome_message <- "The REDCapR delete operation was not successful. The error message was:.+You do not have Delete Record privileges"
expect_error(
returned_object1 <-
redcap_delete(
redcap_uri = credential$redcap_uri,
token = credential$token,
records_to_delete = records_to_delete
),
regexp = expected_outcome_message
)
})

0 comments on commit e77e839

Please sign in to comment.