Skip to content

Commit

Permalink
hugolib: Add some baseof test variants
Browse files Browse the repository at this point in the history
See #2995
  • Loading branch information
bep committed Feb 6, 2017
1 parent 3e5ad4a commit d11f37d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion hugolib/template_test.go
Expand Up @@ -42,17 +42,23 @@ func TestBaseGoTemplate(t *testing.T) {
writeSource(t, fs, filepath.Join("layouts", "section", "sect-baseof.html"), `Base: {{block "main" .}}block{{end}}`)
writeSource(t, fs, filepath.Join("layouts", "section", "sect.html"), `{{define "main"}}sect{{ end }}`)

// See #2995
writeSource(t, fs, filepath.Join("layouts", "sect", "single.html"), `{{define "main"}}single sect{{ end }}`)

// Should not be picked.
writeSource(t, fs, filepath.Join("layouts", "_default", "baseof.html"), `Base: {{block "main" .}}NO{{end}}`)

},
func(t *testing.T) {
assertFileContent(t, fs, filepath.Join("public", "sect", "index.html"), false, "Base: sect")
assertFileContent(t, fs, filepath.Join("public", "sect", "page", "index.html"), false, "Base: single sect")
},
},
{
// Variant 2
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) {
assertFileContent(t, fs, filepath.Join("public", "index.html"), false, "Base: index")
Expand Down Expand Up @@ -88,9 +94,16 @@ func TestBaseGoTemplate(t *testing.T) {
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", "sect.html"), `{{define "main"}}sect{{ end }}`)

// See #2995
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "sect", "single.html"), `{{define "main"}}single sect{{ end }}`)

// Should not be picked.
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "baseof.html"), `Base: {{block "main" .}}NO{{end}}`)

},
func(t *testing.T) {
assertFileContent(t, fs, filepath.Join("public", "sect", "index.html"), false, "Base: sect")
assertFileContent(t, fs, filepath.Join("public", "sect", "page", "index.html"), false, "Base: single sect")
},
},
{
Expand All @@ -100,9 +113,16 @@ func TestBaseGoTemplate(t *testing.T) {
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", "sect.html"), `{{define "main"}}sect{{ end }}`)

// See #2995
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "sect", "single.html"), `{{define "main"}}single sect{{ end }}`)

// Should not be picked.
writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "baseof.html"), `Base: {{block "main" .}}NO{{end}}`)

},
func(t *testing.T) {
assertFileContent(t, fs, filepath.Join("public", "sect", "index.html"), false, "Base Theme: sect")
assertFileContent(t, fs, filepath.Join("public", "sect", "page", "index.html"), false, "Base: single sect")
},
},
{
Expand Down

0 comments on commit d11f37d

Please sign in to comment.