diff options
author | spf13 <steve.francia@gmail.com> | 2014-11-04 00:41:47 -0500 |
---|---|---|
committer | spf13 <steve.francia@gmail.com> | 2014-11-04 00:41:47 -0500 |
commit | 4dcf734acd095654e5c0c64d7c8def8b51813deb (patch) | |
tree | cf9b4dc7889b93dc54eaecd03691dee4e808f85f /hugolib/sitemap_test.go | |
parent | 7b960ac121fa8cdbd9b52c4f2adf66d39440758e (diff) |
Updating tests to use new Targets & Writers and switch to using Afero.MemMapFs for more accurate tests.
Diffstat (limited to 'hugolib/sitemap_test.go')
-rw-r--r-- | hugolib/sitemap_test.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go index f49212694..c51ad06df 100644 --- a/hugolib/sitemap_test.go +++ b/hugolib/sitemap_test.go @@ -4,8 +4,10 @@ import ( "bytes" "testing" + "github.com/spf13/afero" + "github.com/spf13/hugo/helpers" + "github.com/spf13/hugo/hugofs" "github.com/spf13/hugo/source" - "github.com/spf13/hugo/target" "github.com/spf13/viper" ) @@ -21,13 +23,11 @@ const SITEMAP_TEMPLATE = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap </urlset>` func TestSitemapOutput(t *testing.T) { - files := make(map[string][]byte) - target := &target.InMemoryTarget{Files: files} + hugofs.DestinationFS = new(afero.MemMapFs) viper.Set("baseurl", "http://auth/bub/") s := &Site{ - Target: target, Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES}, } @@ -52,12 +52,13 @@ func TestSitemapOutput(t *testing.T) { t.Fatalf("Unable to RenderSitemap: %s", err) } - if _, ok := files["sitemap.xml"]; !ok { - t.Errorf("Unable to locate: sitemap.xml") - t.Logf("%q", files) + sitemapFile, err := hugofs.DestinationFS.Open("sitemap.xml") + + if err != nil { + t.Fatalf("Unable to locate: sitemap.xml") } - sitemap, _ := files["sitemap.xml"] + sitemap := helpers.ReaderToBytes(sitemapFile) if !bytes.HasPrefix(sitemap, []byte("<?xml")) { t.Errorf("Sitemap file should start with <?xml. %s", sitemap) } |