summaryrefslogtreecommitdiffstats
path: root/hugolib/taxonomy_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-23 10:03:48 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-23 10:09:42 +0100
commitc1425a166d3a26fa1789a63a1b6fd0c813dec15e (patch)
treebb67ba0b930d11fae1a6edfb73f1e7f0e4237544 /hugolib/taxonomy_test.go
parent831bfd36aaf18de8ffa6a8f63519ab3e541fa4dd (diff)
hugolib: Fix preserveTaxonomyNames regression
Fixes #3070
Diffstat (limited to 'hugolib/taxonomy_test.go')
-rw-r--r--hugolib/taxonomy_test.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
index bafb2c361..919c3a558 100644
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -49,12 +49,21 @@ func TestByCountOrderOfTaxonomies(t *testing.T) {
}
}
-// Issue #2992
func TestTaxonomiesWithAndWithoutContentFile(t *testing.T) {
+ for _, preserveTaxonomyNames := range []bool{false, true} {
+ t.Run(fmt.Sprintf("preserveTaxonomyNames %t", preserveTaxonomyNames), func(t *testing.T) {
+ doTestTaxonomiesWithAndWithoutContentFile(t, preserveTaxonomyNames)
+ })
+
+ }
+}
+
+func doTestTaxonomiesWithAndWithoutContentFile(t *testing.T, preserveTaxonomyNames bool) {
t.Parallel()
siteConfig := `
baseURL = "http://example.com/blog"
+preserveTaxonomyNames = %t
paginate = 1
defaultContentLanguage = "en"
@@ -77,6 +86,8 @@ others:
# Doc
`
+ siteConfig = fmt.Sprintf(siteConfig, preserveTaxonomyNames)
+
th, h := newTestSitesFromConfigWithDefaultTemplates(t, siteConfig)
require.Len(t, h.Sites, 1)
@@ -85,6 +96,7 @@ others:
writeSource(t, fs, "content/p1.md", fmt.Sprintf(pageTemplate, "t1/c1", "- tag1", "- cat1", "- o1"))
writeSource(t, fs, "content/p2.md", fmt.Sprintf(pageTemplate, "t2/c1", "- tag2", "- cat1", "- o1"))
writeSource(t, fs, "content/p3.md", fmt.Sprintf(pageTemplate, "t2/c12", "- tag2", "- cat2", "- o1"))
+ writeSource(t, fs, "content/p4.md", fmt.Sprintf(pageTemplate, "Hello World", "", "", "- \"Hello Hugo world\""))
writeNewContentFile(t, fs, "Category Terms", "2017-01-01", "content/categories/_index.md", 10)
writeNewContentFile(t, fs, "Tag1 List", "2017-01-01", "content/tags/tag1/_index.md", 10)
@@ -122,4 +134,15 @@ others:
require.Len(t, cat.Data["Pages"], 3)
require.Equal(t, "t1/c1", cat.Pages[0].Title)
+ // Issue #3070 preserveTaxonomyNames
+ if preserveTaxonomyNames {
+ helloWorld := s.getPage(KindTaxonomy, "others", "Hello Hugo world")
+ require.NotNil(t, helloWorld)
+ require.Equal(t, "Hello Hugo world", helloWorld.Title)
+ } else {
+ helloWorld := s.getPage(KindTaxonomy, "others", "hello-hugo-world")
+ require.NotNil(t, helloWorld)
+ require.Equal(t, "Hello Hugo World", helloWorld.Title)
+ }
+
}