mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Rework the Destination filesystem to make --renderStaticToDisk work
See #9626
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user