2017-02-05 03:20:06 +00:00
|
|
|
package helpers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
|
2017-06-13 16:42:45 +00:00
|
|
|
"github.com/gohugoio/hugo/hugofs"
|
2017-02-05 03:20:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func newTestPathSpec(fs *hugofs.Fs, v *viper.Viper) *PathSpec {
|
|
|
|
l := NewDefaultLanguage(v)
|
2017-03-25 13:37:04 +00:00
|
|
|
ps, _ := NewPathSpec(fs, l)
|
|
|
|
return ps
|
2017-02-05 03:20:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func newTestDefaultPathSpec(configKeyValues ...interface{}) *PathSpec {
|
|
|
|
v := viper.New()
|
|
|
|
fs := hugofs.NewMem(v)
|
|
|
|
cfg := newTestCfg(fs)
|
|
|
|
|
|
|
|
for i := 0; i < len(configKeyValues); i += 2 {
|
|
|
|
cfg.Set(configKeyValues[i].(string), configKeyValues[i+1])
|
|
|
|
}
|
|
|
|
return newTestPathSpec(fs, cfg)
|
|
|
|
}
|
|
|
|
|
|
|
|
func newTestCfg(fs *hugofs.Fs) *viper.Viper {
|
|
|
|
v := viper.New()
|
|
|
|
|
|
|
|
v.SetFs(fs.Source)
|
|
|
|
|
|
|
|
return v
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func newTestContentSpec() *ContentSpec {
|
|
|
|
v := viper.New()
|
2017-09-25 06:59:02 +00:00
|
|
|
spec, err := NewContentSpec(v)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return spec
|
2017-02-05 03:20:06 +00:00
|
|
|
}
|