summaryrefslogtreecommitdiffstats
path: root/hugolib/page_taxonomy_test.go
diff options
context:
space:
mode:
authorspf13 <steve.francia@gmail.com>2014-09-05 09:29:01 -0400
committerspf13 <steve.francia@gmail.com>2014-09-05 09:29:01 -0400
commit4bb5e326dbf0f732dd5db45a47fa25999806111e (patch)
tree2aa98b7448214980b2792ff572e2e0ba7685d17c /hugolib/page_taxonomy_test.go
parent1b7f18e39172429545198b3559dcc64bbfb7aa9c (diff)
Taxonomies can now be provided as a single string value if there is only one in frontmatter (tag = "val" vs tag = ["val"])
Diffstat (limited to 'hugolib/page_taxonomy_test.go')
-rw-r--r--hugolib/page_taxonomy_test.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/hugolib/page_taxonomy_test.go b/hugolib/page_taxonomy_test.go
index 68ff4171f..f372a595a 100644
--- a/hugolib/page_taxonomy_test.go
+++ b/hugolib/page_taxonomy_test.go
@@ -20,6 +20,12 @@ categories: 'd'
---
YAML frontmatter with tags and categories taxonomy.`
+var PAGE_YAML_WITH_TAXONOMIES_C = `---
+tags: 'e'
+categories: 'd'
+---
+YAML frontmatter with tags and categories taxonomy.`
+
var PAGE_JSON_WITH_TAXONOMIES = `{
"categories": "d",
"tags": [
@@ -41,6 +47,7 @@ func TestParseTaxonomies(t *testing.T) {
PAGE_JSON_WITH_TAXONOMIES,
PAGE_YAML_WITH_TAXONOMIES_A,
PAGE_YAML_WITH_TAXONOMIES_B,
+ PAGE_YAML_WITH_TAXONOMIES_C,
} {
p, _ := NewPage("page/with/taxonomy")
@@ -50,11 +57,17 @@ func TestParseTaxonomies(t *testing.T) {
}
param := p.GetParam("tags")
- params := param.([]string)
- expected := []string{"a", "b", "c"}
- if !compareStringSlice(params, expected) {
- t.Errorf("Expected %s: got: %s", expected, params)
+ if params, ok := param.([]string); ok {
+ expected := []string{"a", "b", "c"}
+ if !compareStringSlice(params, expected) {
+ t.Errorf("Expected %s: got: %s", expected, params)
+ }
+ } else if params, ok := param.(string); ok {
+ expected := "e"
+ if params != expected {
+ t.Errorf("Expected %s: got: %s", expected, params)
+ }
}
param = p.GetParam("categories")