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/page_permalink_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/page_permalink_test.go')
-rw-r--r-- | hugolib/page_permalink_test.go | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/hugolib/page_permalink_test.go b/hugolib/page_permalink_test.go index 7ea672330..bc89638d3 100644 --- a/hugolib/page_permalink_test.go +++ b/hugolib/page_permalink_test.go @@ -16,12 +16,11 @@ package hugolib import ( "fmt" "html/template" - "path/filepath" "testing" qt "github.com/frankban/quicktest" - "github.com/gohugoio/hugo/deps" + "github.com/gohugoio/hugo/config" ) func TestPermalink(t *testing.T) { @@ -68,28 +67,38 @@ func TestPermalink(t *testing.T) { t.Run(fmt.Sprintf("%s-%d", test.file, i), func(t *testing.T) { t.Parallel() c := qt.New(t) - cfg, fs := newTestCfg() - + cfg := config.New() cfg.Set("uglyURLs", test.uglyURLs) cfg.Set("canonifyURLs", test.canonifyURLs) - cfg.Set("baseURL", test.base) - pageContent := fmt.Sprintf(`--- + files := fmt.Sprintf(` +-- hugo.toml -- +baseURL = %q +-- content/%s -- +--- title: Page slug: %q -url: %q +url: %q output: ["HTML"] --- -Content -`, test.slug, test.url) +`, test.base, test.file, test.slug, test.url) - writeSource(t, fs, filepath.Join("content", filepath.FromSlash(test.file)), pageContent) + if i > 0 { + t.Skip() + } - s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true}) - c.Assert(len(s.RegularPages()), qt.Equals, 1) + b := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + BaseCfg: cfg, + }, + ) + b.Build() + s := b.H.Sites[0] + c.Assert(len(s.RegularPages()), qt.Equals, 1) p := s.RegularPages()[0] - u := p.Permalink() expected := test.expectedAbs |