summaryrefslogtreecommitdiffstats
path: root/helpers/testhelpers_test.go
blob: 303f9feb680cb7970e92a10576f88b464527c7a6 (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
package helpers

import (
	"github.com/spf13/viper"

	"github.com/spf13/hugo/hugofs"
)

func newTestPathSpec(fs *hugofs.Fs, v *viper.Viper) *PathSpec {
	l := NewDefaultLanguage(v)
	return NewPathSpec(fs, l)
}

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()
	return NewContentSpec(v)
}