tests/testthat/test-get_scenario_channels.R

# work around to ensure the package can read in the data
# needs to be saved in the inst folder
path <- system.file("testdata", "three1", "scenario_0", package = "mm.reoptimise") # not ran
path2 <- system.file("testdata", "three2", "scenario_0", package = "mm.reoptimise") # not ran
path3 <- system.file("testdata", "three1", "scenario_1", package = "mm.reoptimise") # already ran

path <- c(path, path2, path3)
scenario_multiple <- purrr::map(path, create_scenario)
output <- purrr::map(scenario_multiple, get_scenario_channels, "month")

names <- c("channel", "period_level2", "channel.group.level1", "channel.group.level2", "channel.group.level3")

test_that("function returns correctly", {

      expect_equal(length(output), length(scenario_multiple))
      expect_equal(typeof(output), "list")
      expect_equal(output[[1]] %>% typeof(), "list")
      expect_equal(output[[1]] %>% names(), names)

})
cath-parkinson/mm.reoptimise documentation built on May 12, 2022, 3:34 p.m.