aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/template_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-12-02 13:23:25 +0100
committerBjørn Erik Pedersen <[email protected]>2020-12-03 13:12:58 +0100
commitd90e37e0c6e812f9913bf256c9c81aa05b7a08aa (patch)
tree7b1b14464eefec1188ca2eed53c64e4823453cc9 /hugolib/template_test.go
parent32471b57bde51c55a15dbf1db75d6e5f7232c347 (diff)
downloadhugo-d90e37e0c6e812f9913bf256c9c81aa05b7a08aa.tar.gz
hugo-d90e37e0c6e812f9913bf256c9c81aa05b7a08aa.zip
all: Format code with gofumpt
See https://github.com/mvdan/gofumpt
Diffstat (limited to 'hugolib/template_test.go')
-rw-r--r--hugolib/template_test.go34
1 files changed, 1 insertions, 33 deletions
diff --git a/hugolib/template_test.go b/hugolib/template_test.go
index 39f1b9e2e..769bcd4e6 100644
--- a/hugolib/template_test.go
+++ b/hugolib/template_test.go
@@ -51,7 +51,6 @@ func TestTemplateLookupOrder(t *testing.T) {
func(t *testing.T) {
writeSource(t, fs, filepath.Join("layouts", "section", "sect1-baseof.html"), `Base: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("layouts", "section", "sect1.html"), `{{define "main"}}sect{{ end }}`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: sect")
@@ -62,7 +61,6 @@ func TestTemplateLookupOrder(t *testing.T) {
func(t *testing.T) {
writeSource(t, fs, filepath.Join("layouts", "baseof.html"), `Base: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("layouts", "index.html"), `{{define "main"}}index{{ end }}`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "index.html"), "Base: index")
@@ -73,7 +71,6 @@ func TestTemplateLookupOrder(t *testing.T) {
func(t *testing.T) {
writeSource(t, fs, filepath.Join("layouts", "_default", "list-baseof.html"), `Base: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"), `{{define "main"}}list{{ end }}`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: list")
@@ -84,7 +81,6 @@ func TestTemplateLookupOrder(t *testing.T) {
func(t *testing.T) {
writeSource(t, fs, filepath.Join("layouts", "_default", "baseof.html"), `Base: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"), `{{define "main"}}list{{ end }}`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: list")
@@ -97,7 +93,6 @@ func TestTemplateLookupOrder(t *testing.T) {
writeSource(t, fs, filepath.Join("layouts", "section", "sect1-baseof.html"), `Base: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "section", "sect-baseof.html"), `Base Theme: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("layouts", "section", "sect1.html"), `{{define "main"}}sect{{ end }}`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: sect")
@@ -109,7 +104,6 @@ func TestTemplateLookupOrder(t *testing.T) {
cfg.Set("theme", "mytheme")
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "section", "sect1-baseof.html"), `Base Theme: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("layouts", "section", "sect1.html"), `{{define "main"}}sect{{ end }}`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base Theme: sect")
@@ -123,7 +117,6 @@ func TestTemplateLookupOrder(t *testing.T) {
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "baseof.html"), `Base Theme: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "list.html"), `{{define "main"}}list{{ end }}`)
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "index.html"), `{{define "main"}}index{{ end }}`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base: list")
@@ -136,7 +129,6 @@ func TestTemplateLookupOrder(t *testing.T) {
cfg.Set("theme", "mytheme")
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "baseof.html"), `Base Theme: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "list.html"), `{{define "main"}}list{{ end }}`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base Theme: list")
@@ -158,7 +150,6 @@ func TestTemplateLookupOrder(t *testing.T) {
// sect2 with list template in /section
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "section", "sect2.html"), `sect2 list`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "sect list")
@@ -170,7 +161,6 @@ func TestTemplateLookupOrder(t *testing.T) {
// Issue #2995
"Test section list and single template selection with base template",
func(t *testing.T) {
-
writeSource(t, fs, filepath.Join("layouts", "_default", "baseof.html"), `Base Default: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("layouts", "sect1", "baseof.html"), `Base Sect1: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("layouts", "section", "sect2-baseof.html"), `Base Sect2: {{block "main" .}}block{{end}}`)
@@ -183,7 +173,6 @@ func TestTemplateLookupOrder(t *testing.T) {
// sect2 with list template in /section
writeSource(t, fs, filepath.Join("layouts", "section", "sect2.html"), `{{define "main"}}sect2 list{{ end }}`)
-
},
func(t *testing.T) {
th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base Sect1", "sect1 list")
@@ -214,7 +203,7 @@ Some content
this.setup(t)
buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
- //helpers.PrintFs(s.BaseFs.Layouts.Fs, "", os.Stdout)
+ // helpers.PrintFs(s.BaseFs.Layouts.Fs, "", os.Stdout)
this.assert(t)
})
@@ -223,7 +212,6 @@ Some content
// https://github.com/gohugoio/hugo/issues/4895
func TestTemplateBOM(t *testing.T) {
-
b := newTestSitesBuilder(t).WithSimpleConfigFile()
bom := "\ufeff"
@@ -242,7 +230,6 @@ Page Content
b.CreateSites().Build(BuildCfg{})
b.AssertFileContent("public/page/index.html", "Base: Hi!?")
-
}
func TestTemplateManyBaseTemplates(t *testing.T) {
@@ -278,7 +265,6 @@ Base %d: {{ block "main" . }}FOO{{ end }}
id := i + 1
b.AssertFileContent(fmt.Sprintf("public/page%d/index.html", id), fmt.Sprintf(`Base %d: %d`, id, id))
}
-
}
// https://github.com/gohugoio/hugo/issues/6790
@@ -315,7 +301,6 @@ title: The Page
b.AssertFileContent("public/blog/p1/index.html", `single`)
b.AssertFileContent("public/blog/index.html", `list`)
-
}
// https://github.com/gohugoio/hugo/issues/6816
@@ -336,7 +321,6 @@ func TestTemplateBaseWithComment(t *testing.T) {
b.Build(BuildCfg{})
b.AssertFileContent("public/index.html", `Base:
Bonjour`)
-
}
func TestTemplateLookupSite(t *testing.T) {
@@ -389,13 +373,10 @@ title: My Page
b.AssertFileContent("public/fr/index.html", `Baseof fr: Main Home Fr`)
b.AssertFileContent("public/en/mysection/index.html", `Baseof mysection: Main Default List`)
b.AssertFileContent("public/en/mysection/p1/index.html", `Baseof mysection: Main Default Single`)
-
})
-
}
func TestTemplateFuncs(t *testing.T) {
-
b := newTestSitesBuilder(t).WithDefaultMultiSiteConfig()
homeTpl := `Site: {{ site.Language.Lang }} / {{ .Site.Language.Lang }} / {{ site.BaseURL }}
@@ -419,11 +400,9 @@ Hugo: {{ hugo.Generator }}
"Sites: en",
"Hugo: <meta name=\"generator\" content=\"Hugo",
)
-
}
func TestPartialWithReturn(t *testing.T) {
-
c := qt.New(t)
newBuilder := func(t testing.TB) *sitesBuilder {
@@ -450,7 +429,6 @@ func TestPartialWithReturn(t *testing.T) {
)
return b
-
}
c.Run("Return", func(c *qt.C) {
@@ -478,7 +456,6 @@ adder: 70: 70
complex: 80: 80
`,
)
-
})
c.Run("Zero argument", func(c *qt.C) {
@@ -495,9 +472,7 @@ add42: fail: {{ partial "add42.tpl" 0 }}
e := b.CreateSites().BuildE(BuildCfg{})
b.Assert(e, qt.Not(qt.IsNil))
-
})
-
}
func TestPartialCached(t *testing.T) {
@@ -600,7 +575,6 @@ title: P1
idset := make(map[identity.Identity]bool)
collectIdentities(idset, templ.(tpl.Info))
b.Assert(idset, qt.HasLen, 11)
-
}
func TestTemplateGoIssues(t *testing.T) {
@@ -636,7 +610,6 @@ func ident(level int) string {
}
func TestPartialInline(t *testing.T) {
-
b := newTestSitesBuilder(t)
b.WithContent("p1.md", "")
@@ -668,11 +641,9 @@ P2: {{ $p2 }}
P1: Inline: p1
P2: 32`,
)
-
}
func TestPartialInlineBase(t *testing.T) {
-
b := newTestSitesBuilder(t)
b.WithContent("p1.md", "")
@@ -712,12 +683,10 @@ P2: 32
P3: Inline: p3
`,
)
-
}
// https://github.com/gohugoio/hugo/issues/7478
func TestBaseWithAndWithoutDefine(t *testing.T) {
-
b := newTestSitesBuilder(t)
b.WithContent("p1.md", "---\ntitle: P\n---\nContent")
@@ -755,5 +724,4 @@ This is home main
This is single main
`,
)
-
}