"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hugolib/cascade_test.go" between
hugo-0.85.0.tar.gz and hugo-0.86.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

cascade_test.go  (hugo-0.85.0):cascade_test.go  (hugo-0.86.0)
skipping to change at line 23 skipping to change at line 23
package hugolib package hugolib
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"path" "path"
"strings" "strings"
"testing" "testing"
"github.com/gohugoio/hugo/common/maps"
qt "github.com/frankban/quicktest" qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/parser" "github.com/gohugoio/hugo/parser"
"github.com/gohugoio/hugo/parser/metadecoders" "github.com/gohugoio/hugo/parser/metadecoders"
) )
func BenchmarkCascade(b *testing.B) { func BenchmarkCascade(b *testing.B) {
allLangs := []string{"en", "nn", "nb", "sv", "ab", "aa", "af", "sq", "kw" , "da"} allLangs := []string{"en", "nn", "nb", "sv", "ab", "aa", "af", "sq", "kw" , "da"}
for i := 1; i <= len(allLangs); i += 2 { for i := 1; i <= len(allLangs); i += 2 {
langs := allLangs[0:i] langs := allLangs[0:i]
skipping to change at line 53 skipping to change at line 55
builder := builders[i] builder := builders[i]
err := builder.BuildE(BuildCfg{}) err := builder.BuildE(BuildCfg{})
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
first := builder.H.Sites[0] first := builder.H.Sites[0]
c.Assert(first, qt.Not(qt.IsNil)) c.Assert(first, qt.Not(qt.IsNil))
} }
}) })
} }
} }
func TestCascadeConfig(t *testing.T) {
c := qt.New(t)
// Make sure the cascade from config gets applied even if we're not
// having a content file for the home page.
for _, withHomeContent := range []bool{true, false} {
testName := "Home content file"
if !withHomeContent {
testName = "No home content file"
}
c.Run(testName, func(c *qt.C) {
b := newTestSitesBuilder(c)
b.WithConfigFile("toml", `
baseURL="https://example.org"
[cascade]
img1 = "img1-config.jpg"
imgconfig = "img-config.jpg"
`)
if withHomeContent {
b.WithContent("_index.md", `
---
title: "Home"
cascade:
img1: "img1-home.jpg"
img2: "img2-home.jpg"
---
`)
}
b.WithContent("p1.md", ``)
b.Build(BuildCfg{})
p1 := b.H.Sites[0].getPage("p1")
if withHomeContent {
b.Assert(p1.Params(), qt.DeepEquals, maps.Params{
"imgconfig": "img-config.jpg",
"draft": bool(false),
"iscjklanguage": bool(false),
"img1": "img1-home.jpg",
"img2": "img2-home.jpg",
})
} else {
b.Assert(p1.Params(), qt.DeepEquals, maps.Params{
"img1": "img1-config.jpg",
"imgconfig": "img-config.jpg",
"draft": bool(false),
"iscjklanguage": bool(false),
})
}
})
}
}
func TestCascade(t *testing.T) { func TestCascade(t *testing.T) {
allLangs := []string{"en", "nn", "nb", "sv"} allLangs := []string{"en", "nn", "nb", "sv"}
langs := allLangs[:3] langs := allLangs[:3]
t.Run(fmt.Sprintf("langs-%d", len(langs)), func(t *testing.T) { t.Run(fmt.Sprintf("langs-%d", len(langs)), func(t *testing.T) {
b := newCascadeTestBuilder(t, langs) b := newCascadeTestBuilder(t, langs)
b.Build(BuildCfg{}) b.Build(BuildCfg{})
b.AssertFileContent("public/index.html", ` b.AssertFileContent("public/index.html", `
 End of changes. 2 change blocks. 
0 lines changed or deleted 65 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)