tests/testthat/test-select_scenario.R

path <- system.file("testdata", "three4", package = "mm.reoptimise")
list_scenario_folders <- create_scenario_list(path)

test_selected_scenario1 <- list_scenario_folders[[1]]
test_selected_scenario2 <- list_scenario_folders[[2]]

output_select_scenario1 <- select_scenario(list_scenario_folders, name = "new")
output_select_scenario2 <- select_scenario(list_scenario_folders, name = "one")
output_select_scenario3 <- select_scenario(list_scenario_folders, name = "ze")

# test function
test_that("selected output matches test object",{
      expect_equal(output_select_scenario2, test_selected_scenario2)
})

test_that("expected charater error message when there is no matching scenario",{
      expect_type(output_select_scenario3, "character")
      expect_equal(output_select_scenario3, "error: no matching scenario")
})
cath-parkinson/mm.reoptimise documentation built on May 12, 2022, 3:34 p.m.