tests/testthat/test-perform_request.R

test_that("perform_request handles API failure correctly", {
  with_mocked_bindings(
    req_perform = function(...) {
      stop("API connection error: Connection timed out")
    },
    expect_error(
      perform_request("sdg4"),
      "Check your internet connection and function parameters."
    )
  )
})

Try the uisapi package in your browser

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

uisapi documentation built on April 3, 2025, 10:02 p.m.