tests/testthat/test-error-grace.R

context("request_and_response")

test_that("Give informative error message when server error", {
  skip_on_cran()
  inform_status <- function(url) {
    params <- list(param_a = "a", param_b = "b")
    response <- httr::RETRY(
      "GET",
      url = url, query = params,
      times = 2, pause_min = 0.5
    )
    stop_for_status(response, context = list(url = url, params = params))
    response
  }
  url <- "http://httpbin.org/status/500"
  expect_error(
    inform_status(url),
    "500"
  )
})

Try the epigraphdb package in your browser

Any scripts or data that you put into this service are public.

epigraphdb documentation built on Jan. 15, 2022, 1:09 a.m.