summaryrefslogtreecommitdiffstats
path: root/hugolib/robotstxt_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-01-10 10:55:03 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-04 11:37:25 +0700
commitc71e1b106e6011d148cac899f83c4685dee33a22 (patch)
treec5c7090f0c2398c7771e4908ebcc97aa7714ffd2 /hugolib/robotstxt_test.go
parent0ada40591216572b0e4c6a8ab986b0aa4fb13c13 (diff)
all: Refactor to nonglobal file systems
Updates #2701 Fixes #2951
Diffstat (limited to 'hugolib/robotstxt_test.go')
-rw-r--r--hugolib/robotstxt_test.go28
1 files changed, 8 insertions, 20 deletions
diff --git a/hugolib/robotstxt_test.go b/hugolib/robotstxt_test.go
index 2faabda7b..1b42011ca 100644
--- a/hugolib/robotstxt_test.go
+++ b/hugolib/robotstxt_test.go
@@ -14,12 +14,12 @@
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/hugo/deps"
"github.com/spf13/viper"
)
@@ -32,28 +32,16 @@ const robotTxtTemplate = `User-agent: Googlebot
func TestRobotsTXTOutput(t *testing.T) {
testCommonResetState()
- hugofs.InitMemFs()
-
viper.Set("baseURL", "http://auth/bub/")
viper.Set("enableRobotsTXT", true)
- s := &Site{
- Source: &source.InMemorySource{ByteSource: weightedSources},
- Language: helpers.NewDefaultLanguage(),
- }
+ fs := hugofs.NewMem()
- if err := buildAndRenderSite(s, "robots.txt", robotTxtTemplate); err != nil {
- t.Fatalf("Failed to build site: %s", err)
- }
+ writeSource(t, fs, filepath.Join("layouts", "robots.txt"), robotTxtTemplate)
+ writeSourcesToSource(t, "content", fs, weightedSources...)
- robotsFile, err := hugofs.Destination().Open("public/robots.txt")
+ buildSingleSite(t, deps.DepsCfg{Fs: fs}, BuildCfg{})
- if err != nil {
- t.Fatalf("Unable to locate: robots.txt")
- }
+ assertFileContent(t, fs, "public/robots.txt", true, "User-agent: Googlebot")
- robots := helpers.ReaderToBytes(robotsFile)
- if !bytes.HasPrefix(robots, []byte("User-agent: Googlebot")) {
- t.Errorf("Robots file should start with 'User-agent: Googlebot'. %s", robots)
- }
}