-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#33 added error handling for http requests to expose actual cromwell …
…server error messages, bump version
- Loading branch information
Showing
6 changed files
with
89 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
response_proof_401 <- list( | ||
error = "Unauthorized" | ||
Check warning on line 2 in tests/testthat/helper-stubs.R GitHub Actions / lint
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# try_url <- function(url) { | ||
# tryCatch(httr::GET(url), error = function(e) e) | ||
# } | ||
|
||
# skip_if_offline("proof-api.fredhutch.org") | ||
|
||
test_that("proof api or DIY cromwell server down", { | ||
# This should happen whether proof or DIY if not on | ||
# campus or VPN for Fred Hutch at least | ||
# and happens if someone puts in a bad url | ||
|
||
httr::set_callback("response", \(req, res) curl::nslookup("abcdefg")) | ||
expect_error( | ||
cromwell_submit_batch(wdl = file_hello, params = file_inputs), | ||
"Unable to resolve host" | ||
) | ||
httr::set_callback("response", NULL) | ||
}) | ||
|
||
test_that("401 unauthorized for proof api", { | ||
# This should only happen with proof api | ||
# regular cromwell server | ||
|
||
webmockr::stub_registry_clear() | ||
webmockr::stub_request("get", make_url(cw_url(), "engine/v1/version")) %>% | ||
webmockr::to_return( | ||
body = jsonlite::toJSON(response_proof_401, auto_unbox = TRUE), | ||
status = 401L, | ||
headers = list("Content-type" = "application/json") | ||
) | ||
|
||
unloadNamespace("vcr") | ||
webmockr::enable(quiet = TRUE) | ||
|
||
expect_error( | ||
cromwell_version(), | ||
"Unauthorized" | ||
) | ||
|
||
webmockr::stub_registry_clear() | ||
webmockr::disable(quiet = TRUE) | ||
}) | ||
|
||
# reload vcr | ||
attachNamespace("vcr") |