tests/testthat/test-auth_verify.R

original_envvar <- Sys.getenv("RTOOT_DEFAULT_TOKEN")
Sys.setenv(RTOOT_DEFAULT_TOKEN = "abc;user;emacs.ch")

test_that("verify_envvar (Good case)", {
  ## The cassette was created with a valid envvar
  vcr::use_cassette("envvar", {
    expect_error(capture_message(verify_envvar()), NA)
  })
})

test_that("verify_envvar (Good case), silent", {
  ## The cassette was created with a valid envvar
  vcr::use_cassette("envvar_silent", {
    expect_silent(verify_envvar(verbose = FALSE))
  })
})

test_that("verify_envvar (Bad case)", {
  Sys.setenv(RTOOT_DEFAULT_TOKEN = "")
  expect_error(verify_envvar())
})

Sys.setenv(RTOOT_DEFAULT_TOKEN = original_envvar)

Try the rtoot package in your browser

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

rtoot documentation built on May 29, 2024, 2:14 a.m.