mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 06:00:25 +03:00
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
This commit is contained in:
parent
e34af6ee30
commit
93ca7c9e95
99 changed files with 2843 additions and 2458 deletions
|
@ -17,10 +17,7 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/hugo/hugofs"
|
||||
|
||||
"github.com/spf13/hugo/deps"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const robotTxtTemplate = `User-agent: Googlebot
|
||||
|
@ -30,18 +27,20 @@ const robotTxtTemplate = `User-agent: Googlebot
|
|||
`
|
||||
|
||||
func TestRobotsTXTOutput(t *testing.T) {
|
||||
testCommonResetState()
|
||||
t.Parallel()
|
||||
var (
|
||||
cfg, fs = newTestCfg()
|
||||
th = testHelper{cfg}
|
||||
)
|
||||
|
||||
viper.Set("baseURL", "http://auth/bub/")
|
||||
viper.Set("enableRobotsTXT", true)
|
||||
|
||||
fs := hugofs.NewMem()
|
||||
cfg.Set("baseURL", "http://auth/bub/")
|
||||
cfg.Set("enableRobotsTXT", true)
|
||||
|
||||
writeSource(t, fs, filepath.Join("layouts", "robots.txt"), robotTxtTemplate)
|
||||
writeSourcesToSource(t, "content", fs, weightedSources...)
|
||||
|
||||
buildSingleSite(t, deps.DepsCfg{Fs: fs}, BuildCfg{})
|
||||
buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
|
||||
|
||||
assertFileContent(t, fs, "public/robots.txt", true, "User-agent: Googlebot")
|
||||
th.assertFileContent(t, fs, "public/robots.txt", true, "User-agent: Googlebot")
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue