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/breaking_changes_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/breaking_changes_test.go')
-rw-r--r-- | hugolib/breaking_changes_test.go | 118 |
1 files changed, 1 insertions, 117 deletions
diff --git a/hugolib/breaking_changes_test.go b/hugolib/breaking_changes_test.go index 495baff3e..533205deb 100644 --- a/hugolib/breaking_changes_test.go +++ b/hugolib/breaking_changes_test.go @@ -1,4 +1,4 @@ -// Copyright 2020 The Hugo Authors. All rights reserved. +// Copyright 2023 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,119 +12,3 @@ // limitations under the License. package hugolib - -import ( - "fmt" - "testing" - - qt "github.com/frankban/quicktest" -) - -func Test073(t *testing.T) { - assertDisabledTaxonomyAndTerm := func(b *sitesBuilder, taxonomy, term bool) { - b.Assert(b.CheckExists("public/tags/index.html"), qt.Equals, taxonomy) - b.Assert(b.CheckExists("public/tags/tag1/index.html"), qt.Equals, term) - } - - assertOutputTaxonomyAndTerm := func(b *sitesBuilder, taxonomy, term bool) { - b.Assert(b.CheckExists("public/tags/index.json"), qt.Equals, taxonomy) - b.Assert(b.CheckExists("public/tags/tag1/index.json"), qt.Equals, term) - } - - for _, this := range []struct { - name string - config string - assert func(err error, out string, b *sitesBuilder) - }{ - { - "Outputs for both taxonomy and taxonomyTerm", - `[outputs] - taxonomy = ["JSON"] - taxonomyTerm = ["JSON"] - -`, - func(err error, out string, b *sitesBuilder) { - b.Assert(err, qt.IsNil) - assertOutputTaxonomyAndTerm(b, true, true) - }, - }, - { - "Outputs for taxonomyTerm", - `[outputs] -taxonomyTerm = ["JSON"] - -`, - func(err error, out string, b *sitesBuilder) { - b.Assert(err, qt.IsNil) - assertOutputTaxonomyAndTerm(b, true, false) - }, - }, - { - "Outputs for taxonomy only", - `[outputs] -taxonomy = ["JSON"] - -`, - func(err error, out string, b *sitesBuilder) { - b.Assert(err, qt.Not(qt.IsNil)) - b.Assert(out, qt.Contains, `ignoreErrors = ["error-output-taxonomy"]`) - }, - }, - { - "Outputs for taxonomy only, ignore error", - ` -ignoreErrors = ["error-output-taxonomy"] -[outputs] -taxonomy = ["JSON"] - -`, - func(err error, out string, b *sitesBuilder) { - b.Assert(err, qt.IsNil) - assertOutputTaxonomyAndTerm(b, true, false) - }, - }, - { - "Disable both taxonomy and taxonomyTerm", - `disableKinds = ["taxonomy", "taxonomyTerm"]`, - func(err error, out string, b *sitesBuilder) { - b.Assert(err, qt.IsNil) - assertDisabledTaxonomyAndTerm(b, false, false) - }, - }, - { - "Disable only taxonomyTerm", - `disableKinds = ["taxonomyTerm"]`, - func(err error, out string, b *sitesBuilder) { - b.Assert(err, qt.IsNil) - assertDisabledTaxonomyAndTerm(b, false, true) - }, - }, - { - "Disable only taxonomy", - `disableKinds = ["taxonomy"]`, - func(err error, out string, b *sitesBuilder) { - b.Assert(err, qt.Not(qt.IsNil)) - b.Assert(out, qt.Contains, `ignoreErrors = ["error-disable-taxonomy"]`) - }, - }, - { - "Disable only taxonomy, ignore error", - `disableKinds = ["taxonomy"] - ignoreErrors = ["error-disable-taxonomy"]`, - func(err error, out string, b *sitesBuilder) { - b.Assert(err, qt.IsNil) - assertDisabledTaxonomyAndTerm(b, false, true) - }, - }, - } { - t.Run(this.name, func(t *testing.T) { - b := newTestSitesBuilder(t).WithConfigFile("toml", this.config) - b.WithTemplatesAdded("_default/list.json", "JSON") - out, err := captureStdout(func() error { - return b.BuildE(BuildCfg{}) - }) - fmt.Println(out) - this.assert(err, out, b) - }) - } -} |