## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = FALSE
)

## -----------------------------------------------------------------------------
# nhsbsa_abort(
#   c("x" = "No resource matched."),
#   class = "nhsbsa_resource_not_found"
# )

## -----------------------------------------------------------------------------
# #' Show a tag
# #'
# #' Wraps the CKAN `tag_show` action.
# #'
# #' @param id Character scalar. The tag name or id.
# #' @inheritParams nhsbsa_package_list
# #'
# #' @return A list of tag metadata.
# #' @export
# #' @examplesIf identical(Sys.getenv("IN_PKGDOWN"), "true")
# #' nhsbsa_tag_show("prescribing")
# nhsbsa_tag_show <- function(id, .return_raw = FALSE) {
#   nhsbsa_query("tag_show")
# }

## -----------------------------------------------------------------------------
# devtools::document() # regenerate NAMESPACE and the .Rd file

## -----------------------------------------------------------------------------
# with_mock_dir("pl", {
#   test_that("nhsbsa_package_list returns dataset ids", {
#     out <- nhsbsa_package_list()
#     expect_type(out, "character")
#   })
# })

## -----------------------------------------------------------------------------
# test_that("an HTTP error surfaces as nhsbsa_api_error", {
#   resp <- httr2::response(
#     status_code = 404L,
#     headers = list(`Content-Type` = "application/json"),
#     body = charToRaw('{"success":false,"error":{"message":"nope"}}')
#   )
#   httr2::with_mocked_responses(function(req) resp, {
#     expect_error(nhsbsa_package_show("x"), class = "nhsbsa_http_404")
#   })
# })

