parser: add some frontmatter test cases - hugo - [fork] hugo port for 9front
(HTM) git clone git@git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit f85d1a7da25fb1d0d6491eabee2860058095fbec
(DIR) parent c641ffea3af2ab16c6449574ea865f2ef10a448e
(HTM) Author: bep <bjorn.erik.pedersen@gmail.com>
Date: Tue, 10 Mar 2015 23:17:39 +0100
parser: add some frontmatter test cases
Diffstat:
M parser/frontmatter.go | 2 --
A parser/frontmatter_test.go | 25 +++++++++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/parser/frontmatter.go b/parser/frontmatter.go
@@ -128,8 +128,6 @@ func FormatToLeadRune(kind string) rune {
switch FormatSanitize(kind) {
case "yaml":
return rune([]byte(YAML_LEAD)[0])
- case "toml":
- return rune([]byte(TOML_LEAD)[0])
case "json":
return rune([]byte(JSON_LEAD)[0])
default:
(DIR) diff --git a/parser/frontmatter_test.go b/parser/frontmatter_test.go
@@ -0,0 +1,25 @@
+package parser
+
+import (
+ "testing"
+)
+
+func TestFormatToLeadRune(t *testing.T) {
+ for i, this := range []struct {
+ kind string
+ expect rune
+ }{
+ {"yaml", '-'},
+ {"yml", '-'},
+ {"toml", '+'},
+ {"json", '{'},
+ {"js", '{'},
+ {"unknown", '+'},
+ } {
+ result := FormatToLeadRune(this.kind)
+
+ if result != this.expect {
+ t.Errorf("[%d] Got %q but expected %q", i, result, this.expect)
+ }
+ }
+}