diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-01-04 18:24:36 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-16 18:01:29 +0200 |
commit | 241b21b0fd34d91fccb2ce69874110dceae6f926 (patch) | |
tree | d4e0118eac7e9c42f065815447a70805f8d6ad3e /resources/resource_transformers/htesting | |
parent | 6aededf6b42011c3039f5f66487a89a8dd65e0e7 (diff) |
Create a struct with all of Hugo's config options
Primary motivation is documentation, but it will also hopefully simplify the code.
Also,
* Lower case the default output format names; this is in line with the custom ones (map keys) and how
it's treated all the places. This avoids doing `stringds.EqualFold` everywhere.
Closes #10896
Closes #10620
Diffstat (limited to 'resources/resource_transformers/htesting')
-rw-r--r-- | resources/resource_transformers/htesting/testhelpers.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/resources/resource_transformers/htesting/testhelpers.go b/resources/resource_transformers/htesting/testhelpers.go index 3c91fc0dd..75ae4245e 100644 --- a/resources/resource_transformers/htesting/testhelpers.go +++ b/resources/resource_transformers/htesting/testhelpers.go @@ -16,18 +16,16 @@ package htesting import ( "path/filepath" - "github.com/gohugoio/hugo/cache/filecache" "github.com/gohugoio/hugo/config" + "github.com/gohugoio/hugo/config/testconfig" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/hugofs" - "github.com/gohugoio/hugo/media" - "github.com/gohugoio/hugo/output" "github.com/gohugoio/hugo/resources" "github.com/spf13/afero" ) func NewTestResourceSpec() (*resources.Spec, error) { - cfg := config.NewWithTestDefaults() + cfg := config.New() imagingCfg := map[string]any{ "resampleFilter": "linear", @@ -36,20 +34,16 @@ func NewTestResourceSpec() (*resources.Spec, error) { } cfg.Set("imaging", imagingCfg) + afs := afero.NewMemMapFs() - fs := hugofs.NewFrom(hugofs.NewBaseFileDecorator(afero.NewMemMapFs()), cfg) - - s, err := helpers.NewPathSpec(fs, cfg, nil) - if err != nil { - return nil, err - } - - filecaches, err := filecache.NewCaches(s) + conf := testconfig.GetTestConfig(afs, cfg) + fs := hugofs.NewFrom(hugofs.NewBaseFileDecorator(afs), conf.BaseConfig()) + s, err := helpers.NewPathSpec(fs, conf, nil) if err != nil { return nil, err } - spec, err := resources.NewSpec(s, filecaches, nil, nil, nil, nil, output.DefaultFormats, media.DefaultTypes) + spec, err := resources.NewSpec(s, nil, nil, nil, nil, nil) return spec, err } |