summaryrefslogtreecommitdiffstats
path: root/hugolib/rss_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-10-14 16:41:55 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-10-14 16:41:55 +0200
commit3ce904669a0d24debc5849c9f1a2f3f5f8fc9f11 (patch)
tree40cad3c6628d90fe86ef8e9233af1f82fca8ab17 /hugolib/rss_test.go
parent588256776ecb4609defacc8b3bafc584b0b045fd (diff)
Rewrite TestRSSOutput to use Afero
When we have a virtual filesystem, we might as well test as close to the iron as possible.
Diffstat (limited to 'hugolib/rss_test.go')
-rw-r--r--hugolib/rss_test.go24
1 files changed, 6 insertions, 18 deletions
diff --git a/hugolib/rss_test.go b/hugolib/rss_test.go
index 007d6a17c..f0ab1c2c3 100644
--- a/hugolib/rss_test.go
+++ b/hugolib/rss_test.go
@@ -14,13 +14,9 @@
package hugolib
import (
- "bytes"
"path/filepath"
"testing"
- "github.com/spf13/hugo/helpers"
- "github.com/spf13/hugo/hugofs"
- "github.com/spf13/hugo/source"
"github.com/spf13/viper"
)
@@ -52,24 +48,16 @@ func TestRSSOutput(t *testing.T) {
viper.Set("baseurl", "http://auth/bub/")
viper.Set("RSSUri", rssURI)
- hugofs.InitMemFs()
- s := &Site{
- Source: &source.InMemorySource{ByteSource: weightedSources},
- Language: helpers.NewDefaultLanguage(),
+ for _, s := range weightedSources {
+ writeSource(t, filepath.Join("content", s.Name), string(s.Content))
}
- if err := buildAndRenderSite(s, "rss.xml", rssTemplate); err != nil {
+ writeSource(t, filepath.Join("layouts", "rss.xml"), rssTemplate)
+
+ if err := buildAndRenderSite(newSiteDefaultLang()); err != nil {
t.Fatalf("Failed to build site: %s", err)
}
- file, err := hugofs.Destination().Open(filepath.Join("public", rssURI))
-
- if err != nil {
- t.Fatalf("Unable to locate: %s", rssURI)
- }
+ assertFileContent(t, filepath.Join("public", rssURI), true, "<?xml", "rss version")
- rss := helpers.ReaderToBytes(file)
- if !bytes.HasPrefix(rss, []byte("<?xml")) {
- t.Errorf("rss feed should start with <?xml. %s", rss)
- }
}