Skip to content

Commit 407c240

Browse files
committed
hugolib: Add test for homepage content for all rendering engines
Update #4166
1 parent c067f34 commit 407c240

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎hugolib/page_test.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
var emptyPage = ""
3636

3737
const (
38+
homePage = "---\ntitle: Home\n---\nHome Page Content\n"
3839
simplePage = "---\ntitle: Simple\n---\nSimple Page\n"
3940
invalidFrontMatterMissing = "This is a test"
4041
renderNoFrontmatter = "<!doctype><html><head></head><body>This is a test</body></html>"
@@ -595,12 +596,22 @@ func testAllMarkdownEnginesForPages(t *testing.T,
595596
writeSource(t, fs, filepath.Join(contentDir, fileSourcePairs[i]), fileSourcePairs[i+1])
596597
}
597598

599+
// Add a content page for the home page
600+
homePath := fmt.Sprintf("_index.%s", e.ext)
601+
writeSource(t, fs, filepath.Join(contentDir, homePath), homePage)
602+
598603
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true})
599604

600605
require.Len(t, s.RegularPages, len(pageSources))
601606

602607
assertFunc(t, e.ext, s.RegularPages)
603608

609+
home, err := s.Info.Home()
610+
require.NoError(t, err)
611+
require.NotNil(t, home)
612+
require.Equal(t, homePath, home.Path())
613+
require.Contains(t, home.Content, "Home Page Content")
614+
604615
}
605616

606617
}

0 commit comments

Comments
 (0)