Rework the Destination filesystem to make --renderStaticToDisk work

See #9626
This commit is contained in:
Bjørn Erik Pedersen
2022-03-21 09:35:15 +01:00
parent b08193971a
commit d070bdf10f
75 changed files with 651 additions and 566 deletions

View File

@@ -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)
}
}

View File

@@ -75,6 +75,11 @@ func NewFrom(params maps.Params) Provider {
}
}
// NewWithTestDefaults is used in tests only.
func NewWithTestDefaults() Provider {
return SetBaseTestDefaults(New())
}
// defaultConfigProvider is a Provider backed by a map where all keys are lower case.
// All methods are thread safe.
type defaultConfigProvider struct {

View File

@@ -54,7 +54,7 @@ disableInlineCSS = true
func TestUseSettingsFromRootIfSet(t *testing.T) {
c := qt.New(t)
cfg := config.New()
cfg := config.NewWithTestDefaults()
cfg.Set("disqusShortname", "root_short")
cfg.Set("googleAnalytics", "ga_root")