tests/testthat/test_001_get_currencies.R

# test_that(
#   "result is as expected",
#   {
#     expect_snapshot_error(
#       x = {
#         api_key("none")
#         get_currencies()
#       },
#       class = "error",
#       cran = FALSE
#     )
#   }
# )

test_that(
  "error suppressed",
  {
    expect_snapshot_output(
      x = {
        api_key("dadada")
        res <- get_currencies(error_on_fail = FALSE)
        res$content$error_message <- grep("You do not have a valid API key.", res$content$error_message)
        res$headers <- NA
        res
      },
      cran = FALSE
    )
  }
)

test_that(
  "correct",
  {
    expect_snapshot_output(
      x = {
        api_key("")
        res <- get_currencies(error_on_fail = FALSE)
        res$headers <- NA
        res
      },
      cran = FALSE
    )
  }
)
rkrug/ROriginStamp documentation built on Aug. 16, 2022, 5:45 p.m.