tests/testthat/test-cache.R

test_that("Test cache", {
  skip_on_cran()
  ## Test remove cache
  if (as.numeric(R.version$major) > 3) {
    cache_file = get_cache_file()

    expect_true(file.exists(cache_file))

    ## Cache the "cache", otherwise tests will become annoyingly slow
    file.copy(cache_file, to = paste0(cache_file, "-testthat"))
    expect_null(remove_cache())
    expect_true(!file.exists(cache_file))
    expect_null(remove_cache()) # Test when no file exists

    ## Reinstate the cache file
    file.copy(from = paste0(cache_file, "-testthat"), cache_file)

  }

}
)

Try the oysteR package in your browser

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

oysteR documentation built on Jan. 11, 2021, 1:36 a.m.