blob: fda1c9ea205463ad60d998bbb989b92fa7ff9bec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package helpers
import (
"github.com/spf13/viper"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/langs"
)
func newTestPathSpec(fs *hugofs.Fs, v *viper.Viper) *PathSpec {
l := langs.NewDefaultLanguage(v)
ps, _ := NewPathSpec(fs, l)
return ps
}
func newTestDefaultPathSpec(configKeyValues ...interface{}) *PathSpec {
v := viper.New()
fs := hugofs.NewMem(v)
cfg := newTestCfgFor(fs)
for i := 0; i < len(configKeyValues); i += 2 {
cfg.Set(configKeyValues[i].(string), configKeyValues[i+1])
}
return newTestPathSpec(fs, cfg)
}
func newTestCfgFor(fs *hugofs.Fs) *viper.Viper {
v := newTestCfg()
v.SetFs(fs.Source)
return v
}
func newTestCfg() *viper.Viper {
v := viper.New()
v.Set("contentDir", "content")
v.Set("dataDir", "data")
v.Set("i18nDir", "i18n")
v.Set("layoutDir", "layouts")
v.Set("archetypeDir", "archetypes")
return v
}
func newTestContentSpec() *ContentSpec {
v := viper.New()
spec, err := NewContentSpec(v)
if err != nil {
panic(err)
}
return spec
}
|