"time"
qt "github.com/frankban/quicktest"
+ "github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugolib"
)
}
func TestPruneImages(t *testing.T) {
+ if htesting.IsCI() {
+ // TODO(bep)
+ t.Skip("skip flaky test on CI server")
+ }
files := `
-- hugo.toml --
baseURL = "https://example.com"
func (c *ConfigCompiled) SetMainSectionsIfNotSet(sections []string) {
c.mu.Lock()
defer c.mu.Unlock()
- if len(c.MainSections) > 0 {
+ if c.MainSections != nil {
return
}
c.MainSections = sections
// Before Hugo 0.112.0 this was configured via site Params.
if mainSections, found := p.c.Params["mainsections"]; found {
p.c.MainSections = types.ToStringSlicePreserveString(mainSections)
+ if p.c.MainSections == nil {
+ p.c.MainSections = []string{}
+ }
}
return nil
`)
}
+
+func TestConfigEmptyMainSections(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.yml --
+params:
+ mainSections:
+-- content/mysection/_index.md --
+-- content/mysection/mycontent.md --
+-- layouts/index.html --
+mainSections: {{ site.Params.mainSections }}
+
+`
+ b := NewIntegrationTestBuilder(
+ IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ },
+ ).Build()
+
+ b.AssertFileContent("public/index.html", `
+mainSections: []
+`)
+
+}