mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
hugolib: Add test for parseSitemap
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/spf13/hugo/hugofs"
|
"github.com/spf13/hugo/hugofs"
|
||||||
"github.com/spf13/hugo/source"
|
"github.com/spf13/hugo/source"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
const SITEMAP_TEMPLATE = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
const SITEMAP_TEMPLATE = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
@@ -83,3 +84,19 @@ func TestSitemapOutput(t *testing.T) {
|
|||||||
t.Errorf("Sitemap file should start with <?xml. %s", sitemap)
|
t.Errorf("Sitemap file should start with <?xml. %s", sitemap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseSitemap(t *testing.T) {
|
||||||
|
expected := Sitemap{Priority: 3.0, Filename: "doo.xml", ChangeFreq: "3"}
|
||||||
|
input := map[string]interface{}{
|
||||||
|
"changefreq": "3",
|
||||||
|
"priority": 3.0,
|
||||||
|
"filename": "doo.xml",
|
||||||
|
"unknown": "ignore",
|
||||||
|
}
|
||||||
|
result := parseSitemap(input)
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(expected, result) {
|
||||||
|
t.Errorf("Got \n%v expected \n%v", result, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user