diff options
Diffstat (limited to 'config/configProvider.go')
-rw-r--r-- | config/configProvider.go | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/config/configProvider.go b/config/configProvider.go index cf4c3dab3..01a2e8c54 100644 --- a/config/configProvider.go +++ b/config/configProvider.go @@ -45,13 +45,23 @@ func GetStringSlicePreserveString(cfg Provider, key string) []string { } // SetBaseTestDefaults provides some common config defaults used in tests. -func SetBaseTestDefaults(cfg Provider) { - cfg.Set("resourceDir", "resources") - cfg.Set("contentDir", "content") - cfg.Set("dataDir", "data") - cfg.Set("i18nDir", "i18n") - cfg.Set("layoutDir", "layouts") - cfg.Set("assetDir", "assets") - cfg.Set("archetypeDir", "archetypes") - cfg.Set("publishDir", "public") +func SetBaseTestDefaults(cfg Provider) Provider { + setIfNotSet(cfg, "baseURL", "https://example.org") + setIfNotSet(cfg, "resourceDir", "resources") + setIfNotSet(cfg, "contentDir", "content") + setIfNotSet(cfg, "dataDir", "data") + setIfNotSet(cfg, "i18nDir", "i18n") + setIfNotSet(cfg, "layoutDir", "layouts") + setIfNotSet(cfg, "assetDir", "assets") + setIfNotSet(cfg, "archetypeDir", "archetypes") + setIfNotSet(cfg, "publishDir", "public") + setIfNotSet(cfg, "workingDir", "") + setIfNotSet(cfg, "defaultContentLanguage", "en") + return cfg +} + +func setIfNotSet(cfg Provider, key string, value any) { + if !cfg.IsSet(key) { + cfg.Set(key, value) + } } |