tests/testthat/test-utils.R

library(testthat)
library(fingertipsR)

context("API error handling")

test_that("Unavailable endpoint gives error message", {
        skip_if_offline()
        expect_error(area_types(path = "junk"),
                     "The API is currently unavailable")
        })

test_that("Unavailable endpoint gives error message - real url", {
        skip_if_offline()
        expect_error(area_types(path = "httpstat.us/500"),
                     "The API is currently unavailable")
})

Try the fingertipsR package in your browser

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

fingertipsR documentation built on Sept. 16, 2020, 5:07 p.m.