From 241b21b0fd34d91fccb2ce69874110dceae6f926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 4 Jan 2023 18:24:36 +0100 Subject: 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 --- hugolib/pages_capture_test.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'hugolib/pages_capture_test.go') diff --git a/hugolib/pages_capture_test.go b/hugolib/pages_capture_test.go index ea2ef4e1e..8c1023a15 100644 --- a/hugolib/pages_capture_test.go +++ b/hugolib/pages_capture_test.go @@ -19,24 +19,22 @@ import ( "path/filepath" "testing" - "github.com/gohugoio/hugo/helpers" - "github.com/gohugoio/hugo/source" - - "github.com/gohugoio/hugo/common/loggers" - qt "github.com/frankban/quicktest" - "github.com/gohugoio/hugo/hugofs" + "github.com/gohugoio/hugo/common/loggers" + "github.com/gohugoio/hugo/config" + "github.com/gohugoio/hugo/config/testconfig" + "github.com/gohugoio/hugo/source" "github.com/spf13/afero" ) func TestPagesCapture(t *testing.T) { - cfg, hfs := newTestCfg() - fs := hfs.Source c := qt.New(t) + afs := afero.NewMemMapFs() + writeFile := func(filename string) { - c.Assert(afero.WriteFile(fs, filepath.FromSlash(filename), []byte(fmt.Sprintf("content-%s", filename)), 0755), qt.IsNil) + c.Assert(afero.WriteFile(afs, filepath.Join("content", filepath.FromSlash(filename)), []byte(fmt.Sprintf("content-%s", filename)), 0755), qt.IsNil) } writeFile("_index.md") @@ -47,19 +45,20 @@ func TestPagesCapture(t *testing.T) { writeFile("blog/images/sunset.png") writeFile("pages/page1.md") writeFile("pages/page2.md") - writeFile("pages/page.png") - ps, err := helpers.NewPathSpec(hugofs.NewFrom(fs, cfg), cfg, loggers.NewErrorLogger()) - c.Assert(err, qt.IsNil) - sourceSpec := source.NewSourceSpec(ps, nil, fs) + cfg := config.New() + d := testconfig.GetTestDeps(afs, cfg) + sourceSpec := source.NewSourceSpec(d.PathSpec, nil, d.BaseFs.Content.Fs) t.Run("Collect", func(t *testing.T) { c := qt.New(t) proc := &testPagesCollectorProcessor{} coll := newPagesCollector(sourceSpec, nil, loggers.NewErrorLogger(), nil, proc) c.Assert(coll.Collect(), qt.IsNil) - c.Assert(len(proc.items), qt.Equals, 4) + // 2 bundles, 3 pages. + c.Assert(len(proc.items), qt.Equals, 5) }) + } type testPagesCollectorProcessor struct { -- cgit v1.2.3