diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-05 10:19:55 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-05 11:22:03 +0200 |
commit | de87624241daa86660f205cc72a745409b9c9238 (patch) | |
tree | 361e6ae2c801bd400bf9d1de8c9fda64c5750dca /hugolib/site_output_test.go | |
parent | 9ef4dca361727a78e0f66f8f4e54c64e4c4781cb (diff) |
hugolib: Fix output format handling of mix cased page kinds
Fixes #4528
Diffstat (limited to 'hugolib/site_output_test.go')
-rw-r--r-- | hugolib/site_output_test.go | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/hugolib/site_output_test.go b/hugolib/site_output_test.go index 1536817b0..90e023225 100644 --- a/hugolib/site_output_test.go +++ b/hugolib/site_output_test.go @@ -327,33 +327,53 @@ baseName = "customdelimbase" } func TestCreateSiteOutputFormats(t *testing.T) { - assert := require.New(t) - outputsConfig := map[string]interface{}{ - page.KindHome: []string{"HTML", "JSON"}, - page.KindSection: []string{"JSON"}, - } + t.Run("Basic", func(t *testing.T) { + assert := require.New(t) - cfg := viper.New() - cfg.Set("outputs", outputsConfig) + outputsConfig := map[string]interface{}{ + page.KindHome: []string{"HTML", "JSON"}, + page.KindSection: []string{"JSON"}, + } - outputs, err := createSiteOutputFormats(output.DefaultFormats, cfg) - assert.NoError(err) - assert.Equal(output.Formats{output.JSONFormat}, outputs[page.KindSection]) - assert.Equal(output.Formats{output.HTMLFormat, output.JSONFormat}, outputs[page.KindHome]) - - // Defaults - assert.Equal(output.Formats{output.HTMLFormat, output.RSSFormat}, outputs[page.KindTaxonomy]) - assert.Equal(output.Formats{output.HTMLFormat, output.RSSFormat}, outputs[page.KindTaxonomyTerm]) - assert.Equal(output.Formats{output.HTMLFormat}, outputs[page.KindPage]) - - // These aren't (currently) in use when rendering in Hugo, - // but the pages needs to be assigned an output format, - // so these should also be correct/sensible. - assert.Equal(output.Formats{output.RSSFormat}, outputs[kindRSS]) - assert.Equal(output.Formats{output.SitemapFormat}, outputs[kindSitemap]) - assert.Equal(output.Formats{output.RobotsTxtFormat}, outputs[kindRobotsTXT]) - assert.Equal(output.Formats{output.HTMLFormat}, outputs[kind404]) + cfg := viper.New() + cfg.Set("outputs", outputsConfig) + + outputs, err := createSiteOutputFormats(output.DefaultFormats, cfg) + assert.NoError(err) + assert.Equal(output.Formats{output.JSONFormat}, outputs[page.KindSection]) + assert.Equal(output.Formats{output.HTMLFormat, output.JSONFormat}, outputs[page.KindHome]) + + // Defaults + assert.Equal(output.Formats{output.HTMLFormat, output.RSSFormat}, outputs[page.KindTaxonomy]) + assert.Equal(output.Formats{output.HTMLFormat, output.RSSFormat}, outputs[page.KindTaxonomyTerm]) + assert.Equal(output.Formats{output.HTMLFormat}, outputs[page.KindPage]) + + // These aren't (currently) in use when rendering in Hugo, + // but the pages needs to be assigned an output format, + // so these should also be correct/sensible. + assert.Equal(output.Formats{output.RSSFormat}, outputs[kindRSS]) + assert.Equal(output.Formats{output.SitemapFormat}, outputs[kindSitemap]) + assert.Equal(output.Formats{output.RobotsTxtFormat}, outputs[kindRobotsTXT]) + assert.Equal(output.Formats{output.HTMLFormat}, outputs[kind404]) + + }) + + // Issue #4528 + t.Run("Mixed case", func(t *testing.T) { + assert := require.New(t) + cfg := viper.New() + + outputsConfig := map[string]interface{}{ + "taxonomyterm": []string{"JSON"}, + } + cfg.Set("outputs", outputsConfig) + + outputs, err := createSiteOutputFormats(output.DefaultFormats, cfg) + assert.NoError(err) + assert.Equal(output.Formats{output.JSONFormat}, outputs[page.KindTaxonomyTerm]) + + }) } |