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 /hugolib/pages_capture_test.go | |
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 'hugolib/pages_capture_test.go')
-rw-r--r-- | hugolib/pages_capture_test.go | 27 |
1 files changed, 13 insertions, 14 deletions
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 { |