From c12f65ca9abe0aab45a692cf469cf6a509cfedd9 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 20 Nov 2024 20:01:38 -0600 Subject: [PATCH] don't expect error something in curl must have changed? The bad url is still not sucessful (which is good). But now it's reflectedin a 403 http code, instead of an R error. --- tests/testthat/test-event-instruments.R | 12 ++++++++---- tests/testthat/test-instruments-metadata.R | 11 +++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-event-instruments.R b/tests/testthat/test-event-instruments.R index 50a50829..6554d610 100644 --- a/tests/testthat/test-event-instruments.R +++ b/tests/testthat/test-event-instruments.R @@ -123,20 +123,24 @@ test_that("2-arms-retrieve-only-arm-2", { test_that("Bad URI", { testthat::skip_on_cran() bad_uri <- "https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com" - expected_data_frame <- structure(list(), .Names = character(0), row.names = integer(0), class = "data.frame") + # expected_data_frame <- structure(list(), .Names = character(0), row.names = integer(0), class = "data.frame") # Windows gives a different message than Travis/Linux - expected_outcome_message <- "(https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com|Couldn't resolve host 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com')" + # expected_outcome_message <- "(https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com|Couldn't resolve host 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com')" # "The REDCapR variable retrieval was not successful\\..+?Error 405 \\(Method Not Allowed\\).+" # expected_outcome_message <- "(?s)The REDCapR variable retrieval was not successful\\..+?.+" - expect_error( + # expect_error( returned_object <- redcap_event_instruments( redcap_uri = bad_uri, token = credential_longitudinal$token, verbose = FALSE ) - ) + # ) + + expect_false(returned_object$success) + expect_equal(returned_object$status_code, 403L) + expect_match(returned_object$outcome_message, "The REDCapR instrument retrieval was not successful.+") }) test_that("no-arms", { testthat::skip_on_cran() diff --git a/tests/testthat/test-instruments-metadata.R b/tests/testthat/test-instruments-metadata.R index f7660198..e3b5c175 100644 --- a/tests/testthat/test-instruments-metadata.R +++ b/tests/testthat/test-instruments-metadata.R @@ -40,21 +40,24 @@ test_that("default", { test_that("Bad URI", { testthat::skip_on_cran() bad_uri <- "https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com" - expected_data_frame <- structure(list(), .Names = character(0), row.names = integer(0), class = "data.frame") + # expected_data_frame <- structure(list(), .Names = character(0), row.names = integer(0), class = "data.frame") # Windows gives a different message than Travis/Linux - expected_outcome_message <- "(https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com|Couldn't resolve host 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com')" + # expected_outcome_message <- "(https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com|Couldn't resolve host 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com')" # "The REDCapR variable retrieval was not successful\\..+?Error 405 \\(Method Not Allowed\\).+" # expected_outcome_message <- "(?s)The REDCapR variable retrieval was not successful\\..+?.+" - expect_error( + # expect_error( returned_object <- redcap_instruments( redcap_uri = bad_uri, token = credential$token, verbose = FALSE ) - ) + # ) + expect_false(returned_object$success) + expect_equal(returned_object$status_code, 403L) + expect_match(returned_object$outcome_message, "The REDCapR instrument retrieval was not successful.+") }) test_that("bad token -Error", {