Add hugo.WorkingDir

Fixes #10969
This commit is contained in:
Bjørn Erik Pedersen
2023-05-20 15:04:22 +02:00
parent 4f085e80da
commit 7c7baa6183
11 changed files with 86 additions and 14 deletions

View File

@@ -25,8 +25,8 @@ import (
func TestPageMatcher(t *testing.T) {
c := qt.New(t)
developmentTestSite := testSite{h: hugo.NewInfo("development", nil)}
productionTestSite := testSite{h: hugo.NewInfo("production", nil)}
developmentTestSite := testSite{h: hugo.NewInfo(testConfig{environment: "development"}, nil)}
productionTestSite := testSite{h: hugo.NewInfo(testConfig{environment: "production"}, nil)}
p1, p2, p3 :=
&testPage{path: "/p1", kind: "section", lang: "en", site: developmentTestSite},
@@ -156,3 +156,16 @@ func TestDecodeCascadeConfig(t *testing.T) {
c.Assert(got, qt.IsNotNil)
}
type testConfig struct {
environment string
workingDir string
}
func (c testConfig) Environment() string {
return c.environment
}
func (c testConfig) WorkingDir() string {
return c.workingDir
}

View File

@@ -444,9 +444,9 @@ func (s testSite) Param(key any) (any, error) {
}
// NewDummyHugoSite creates a new minimal test site.
func NewDummyHugoSite(cfg config.Provider) Site {
func NewDummyHugoSite(conf config.AllProvider) Site {
return testSite{
h: hugo.NewInfo(hugo.EnvironmentProduction, nil),
h: hugo.NewInfo(conf, nil),
l: &langs.Language{
Lang: "en",
},