diff options
author | Bjørn Erik Pedersen <[email protected]> | 2016-11-09 19:59:28 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2016-11-22 09:57:03 +0100 |
commit | d3d3863c05c4cd3c3f22eb9e977bcf407a903c45 (patch) | |
tree | e7363ec90d1f4e35f75fabbef379831be050d009 /hugolib/sitemap_test.go | |
parent | 7cc637e97a596336d1c64c203cb089e9de84ec45 (diff) | |
download | hugo-d3d3863c05c4cd3c3f22eb9e977bcf407a903c45.tar.gz hugo-d3d3863c05c4cd3c3f22eb9e977bcf407a903c45.zip |
node to page: Add all nodes to sitemap
Updates #2297
Fixes #1303
Diffstat (limited to 'hugolib/sitemap_test.go')
-rw-r--r-- | hugolib/sitemap_test.go | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go index 0ec51497a..72fcb2048 100644 --- a/hugolib/sitemap_test.go +++ b/hugolib/sitemap_test.go @@ -17,7 +17,6 @@ import ( "testing" "reflect" - "strings" "github.com/spf13/hugo/helpers" "github.com/spf13/hugo/source" @@ -36,6 +35,12 @@ const SITEMAP_TEMPLATE = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap </urlset>` func TestSitemapOutput(t *testing.T) { + for _, internal := range []bool{false, true} { + doTestSitemapOutput(t, internal) + } +} + +func doTestSitemapOutput(t *testing.T, internal bool) { testCommonResetState() viper.Set("baseURL", "http://auth/bub/") @@ -45,15 +50,30 @@ func TestSitemapOutput(t *testing.T) { Language: helpers.NewDefaultLanguage(), } - if err := buildAndRenderSite(s, "sitemap.xml", SITEMAP_TEMPLATE); err != nil { - t.Fatalf("Failed to build site: %s", err) + if internal { + if err := buildAndRenderSite(s); err != nil { + t.Fatalf("Failed to build site: %s", err) + } + + } else { + if err := buildAndRenderSite(s, "sitemap.xml", SITEMAP_TEMPLATE); err != nil { + t.Fatalf("Failed to build site: %s", err) + } } - sitemapContent := readDestination(t, "public/sitemap.xml") + assertFileContent(t, "public/sitemap.xml", true, + // Regular page + " <loc>http://auth/bub/sect/doc1/</loc>", + // Home page + "<loc>http://auth/bub/</loc>", + // Section + "<loc>http://auth/bub/sect/</loc>", + // Tax terms + "<loc>http://auth/bub/categories/</loc>", + // Tax list + "<loc>http://auth/bub/categories/hugo/</loc>", + ) - if !strings.HasPrefix(sitemapContent, "<?xml") { - t.Errorf("Sitemap file should start with <?xml. %s", sitemapContent) - } } func TestParseSitemap(t *testing.T) { |