tests/testthat/test-parent.R

test_that("config file is discovered in parent directory", {
  expect_identical(config::get("color", file = "parent/child/config.yml"),
                   "red")
})

test_that("use_parent prevents scanning of parent directories", {
  expect_error(config::get("color",
                           file = "parent/child/config.yml",
                           use_parent = FALSE),
               regexp = "not found in current working")

})

test_that("search for config file properly terminates", {
  expect_error(config::get("color", file = "parent/child/notexists.yml"),
               regexp = "not found in current working")
})

test_that("search for config file works without directory", {
  old <- setwd("parent")
  on.exit(setwd(old))
  expect_identical(config::get("color", file = "config-multiple.yml"),
                   "red")
})

Try the config package in your browser

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

config documentation built on Aug. 30, 2023, 5:16 p.m.