tests/testthat/test-finbif_token.R

test_that("is a string", {

  tokn <- Sys.getenv("FINBIF_ACCESS_TOKEN")
  if (identical(tokn, "")) {
    expect_null(token())
  } else {
    expect_type(token(), "character")
  }

})

test_that("retrival produces a message", {

  expect_message(token(quiet = FALSE))

})

test_that("returns NULL when unset", {

  tokn <- Sys.getenv("FINBIF_ACCESS_TOKEN")
  Sys.unsetenv("FINBIF_ACCESS_TOKEN")
  expect_null(token())
  Sys.setenv(FINBIF_ACCESS_TOKEN = tokn)

})

Try the finbif package in your browser

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

finbif documentation built on Jan. 3, 2022, 5:09 p.m.