tests/testthat.R

library(testthat)
library(Rnightlights)

## force tests to be executed if in dev release which we define as
## having a sub-release, eg 0.9.15.5 is one whereas 0.9.16 is not
if (length(strsplit(packageDescription("Rnightlights")$Version, "\\.")[[1]]) > 3) {	# dev release, and
  if (Sys.getenv("RunAllTests") != "no") { 				# if env.var not explicitly set to no
    message("Setting \"RunAllTests\"=\"yes\" for development release\n")
    Sys.setenv("RunAllTests"="yes")
  }
}

setup({
  #set the dataPath to tempdir() to ensure a clean environment for tests
  #thus forcing polygon and tile downloads and fresh raster
  #clipping and data extraction
  currDir <<- getNlDataPath()
  
  tempDir <<- tempdir()

  Rnightlights:::setNlDataPath(tempDir)
})

test_check("Rnightlights")

teardown({
  Rnightlights:::setNlDataPath(currDir)
  
  unlink(tempDir, recursive = T, force = TRUE)
})

Try the Rnightlights package in your browser

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

Rnightlights documentation built on Aug. 29, 2019, 5:02 p.m.