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")
})
rstudio/config documentation built on April 4, 2024, 6:27 a.m.