summaryrefslogtreecommitdiffstats
path: root/hugolib/alias_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-05 10:20:06 +0700
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-17 17:15:26 +0100
commit93ca7c9e958e34469a337e4efcc7c75774ec50fd (patch)
tree5dfa296cfe74fd5ef8f0d41ea4078704f453aa04 /hugolib/alias_test.go
parente34af6ee30f70f5780a281e2fd8f4ed9b487ee61 (diff)
all: Refactor to nonglobal Viper, i18n etc.
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
Diffstat (limited to 'hugolib/alias_test.go')
-rw-r--r--hugolib/alias_test.go27
1 files changed, 16 insertions, 11 deletions
diff --git a/hugolib/alias_test.go b/hugolib/alias_test.go
index 22803d22e..653156495 100644
--- a/hugolib/alias_test.go
+++ b/hugolib/alias_test.go
@@ -18,7 +18,6 @@ import (
"testing"
"github.com/spf13/hugo/deps"
- "github.com/spf13/hugo/hugofs"
"github.com/stretchr/testify/require"
)
@@ -33,38 +32,44 @@ const basicTemplate = "<html><body>{{.Content}}</body></html>"
const aliasTemplate = "<html><body>ALIASTEMPLATE</body></html>"
func TestAlias(t *testing.T) {
- testCommonResetState()
+ t.Parallel()
- fs := hugofs.NewMem()
+ var (
+ cfg, fs = newTestCfg()
+ th = testHelper{cfg}
+ )
writeSource(t, fs, filepath.Join("content", "page.md"), pageWithAlias)
writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), basicTemplate)
- buildSingleSite(t, deps.DepsCfg{Fs: fs}, BuildCfg{})
+ buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
// the real page
- assertFileContent(t, fs, filepath.Join("public", "page", "index.html"), false, "For some moments the old man")
+ th.assertFileContent(t, fs, filepath.Join("public", "page", "index.html"), false, "For some moments the old man")
// the alias redirector
- assertFileContent(t, fs, filepath.Join("public", "foo", "bar", "index.html"), false, "<meta http-equiv=\"refresh\" content=\"0; ")
+ th.assertFileContent(t, fs, filepath.Join("public", "foo", "bar", "index.html"), false, "<meta http-equiv=\"refresh\" content=\"0; ")
}
func TestAliasTemplate(t *testing.T) {
- testCommonResetState()
+ t.Parallel()
- fs := hugofs.NewMem()
+ var (
+ cfg, fs = newTestCfg()
+ th = testHelper{cfg}
+ )
writeSource(t, fs, filepath.Join("content", "page.md"), pageWithAlias)
writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), basicTemplate)
writeSource(t, fs, filepath.Join("layouts", "alias.html"), aliasTemplate)
- sites, err := NewHugoSitesFromConfiguration(deps.DepsCfg{Fs: fs})
+ sites, err := NewHugoSites(deps.DepsCfg{Fs: fs, Cfg: cfg})
require.NoError(t, err)
require.NoError(t, sites.Build(BuildCfg{}))
// the real page
- assertFileContent(t, fs, filepath.Join("public", "page", "index.html"), false, "For some moments the old man")
+ th.assertFileContent(t, fs, filepath.Join("public", "page", "index.html"), false, "For some moments the old man")
// the alias redirector
- assertFileContent(t, fs, filepath.Join("public", "foo", "bar", "index.html"), false, "ALIASTEMPLATE")
+ th.assertFileContent(t, fs, filepath.Join("public", "foo", "bar", "index.html"), false, "ALIASTEMPLATE")
}