tests/testthat/test_MODIStsp_resetindexes.R

context("MODIStsp_resetindexes")


test_that("MODIStsp_resetindexes works as expected", {
  skip_on_cran()
  # add a custom index
  expect_message(
    MODIStsp_addindex(
      opts_jsfile = system.file("testdata/test_addindex.json",
                                  package = "MODIStsp"),
      gui = FALSE,
      new_indexbandname = paste0("Index_", as.character(sample(10000, 1))),
      new_indexformula = "b1_Red - b2_NIR",
      new_indexfullname = paste0("Index_", as.character(sample(10000, 1))))
  )
  # remove it and check if custom indexes were removed
  MODIStsp_resetindexes(
    opts_jsfile = system.file("testdata/test_addindex.json",
                                package = "MODIStsp")
  )
  opts <- load_opts(system.file("testdata/test_addindex.json",
                                package = "MODIStsp"))
  expect_equal(length(opts$custom_indexes), 0)

})

Try the MODIStsp package in your browser

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

MODIStsp documentation built on Dec. 4, 2018, 1:04 a.m.