@@ -18,6 +18,8 @@ import (
1818
1919 "reflect"
2020
21+ "github.com/stretchr/testify/require"
22+
2123 "github.com/spf13/hugo/deps"
2224 "github.com/spf13/hugo/tpl"
2325)
@@ -47,18 +49,24 @@ func doTestSitemapOutput(t *testing.T, internal bool) {
4749
4850 depsCfg := deps.DepsCfg {Fs : fs , Cfg : cfg }
4951
50- if ! internal {
51- depsCfg . WithTemplate = func ( templ tpl. TemplateHandler ) error {
52+ depsCfg . WithTemplate = func ( templ tpl. TemplateHandler ) error {
53+ if ! internal {
5254 templ .AddTemplate ("sitemap.xml" , sitemapTemplate )
53- return nil
5455 }
56+
57+ // We want to check that the 404 page is not included in the sitemap
58+ // output. This template should have no effect either way, but include
59+ // it for the clarity.
60+ templ .AddTemplate ("404.html" , "Not found" )
61+ return nil
5562 }
5663
5764 writeSourcesToSource (t , "content" , fs , weightedSources ... )
5865 s := buildSingleSite (t , depsCfg , BuildCfg {})
5966 th := testHelper {s .Cfg , s .Fs , t }
67+ outputSitemap := "public/sitemap.xml"
6068
61- th .assertFileContent ("public/sitemap.xml" ,
69+ th .assertFileContent (outputSitemap ,
6270 // Regular page
6371 " <loc>http://auth/bub/sect/doc1/</loc>" ,
6472 // Home page
@@ -71,6 +79,9 @@ func doTestSitemapOutput(t *testing.T, internal bool) {
7179 "<loc>http://auth/bub/categories/hugo/</loc>" ,
7280 )
7381
82+ content := readDestination (th .T , th .Fs , outputSitemap )
83+ require .NotContains (t , content , "404" )
84+
7485}
7586
7687func TestParseSitemap (t * testing.T ) {
0 commit comments