2017-02-04 22:20:06 -05:00
|
|
|
package helpers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
|
2017-06-13 12:42:45 -04:00
|
|
|
"github.com/gohugoio/hugo/hugofs"
|
2017-02-04 22:20:06 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func newTestPathSpec(fs *hugofs.Fs, v *viper.Viper) *PathSpec {
|
|
|
|
l := NewDefaultLanguage(v)
|
2017-03-25 09:37:04 -04:00
|
|
|
ps, _ := NewPathSpec(fs, l)
|
|
|
|
return ps
|
2017-02-04 22:20:06 -05: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()
|
2018-03-21 12:21:46 -04:00
|
|
|
v.Set("contentDir", "content")
|
2017-02-04 22:20:06 -05:00
|
|
|
|
|
|
|
v.SetFs(fs.Source)
|
|
|
|
|
|
|
|
return v
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func newTestContentSpec() *ContentSpec {
|
|
|
|
v := viper.New()
|
2017-09-25 02:59:02 -04:00
|
|
|
spec, err := NewContentSpec(v)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return spec
|
2017-02-04 22:20:06 -05:00
|
|
|
}
|