tests/testthat/test-call_api.R

test_that("setting temporary cache dir works", {
  # verify that cache_dir is not set
  options(sfa_cache_dir = NULL)
  expect_identical(getOption("sfa_cache_dir"), NULL)

  # download any data
  expect_warning(
    checkmate::expect_data_table(
      sfa_get_entities(cache_dir = NULL)
    ),
    "'cache_dir' not set. Defaulting to 'tempdir()'. Thus, API results will only be cached during this session. To learn why and how to cache results over the end of this session, see `?sfa_set_cache_dir`.\n\n[This warning appears only once per session.]",
    fixed = TRUE
  )

  # verify that cache_dir is set
  expect_identical(getOption("sfa_cache_dir"), tempdir())
})

Try the simfinapi package in your browser

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

simfinapi documentation built on April 14, 2023, 12:27 a.m.