tests/testthat/test-inherit.R

test_that("configurations inherit from default", {
  conf <- config::get(config = "development")
  expect_identical(conf$color, "red")
  expect_identical(conf$shape, "triangle")
})

test_that("configurations can inherit from other configurations", {
  conf <- config::get(config = "test")
  expect_identical(conf$shape, "triangle")
})

test_that("configuration inheriting from itself is an error", {
  expect_error(config::get(config = "test", file = "config-inheritself.yml"),
               regexp = "inherits from itself")
})

test_that("configurations can inherit from multiple other configurations", {
  config <- config::get(config = "west", file = "config-multiple.yml")
  expect_identical(config$shape, "hexagon")
  expect_identical(config$log, TRUE)
})

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.