mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-17 16:39:44 +00:00
parser: add some frontmatter test cases
This commit is contained in:
parent
c641ffea3a
commit
f85d1a7da2
2 changed files with 25 additions and 2 deletions
|
@ -128,8 +128,6 @@ func FormatToLeadRune(kind string) rune {
|
||||||
switch FormatSanitize(kind) {
|
switch FormatSanitize(kind) {
|
||||||
case "yaml":
|
case "yaml":
|
||||||
return rune([]byte(YAML_LEAD)[0])
|
return rune([]byte(YAML_LEAD)[0])
|
||||||
case "toml":
|
|
||||||
return rune([]byte(TOML_LEAD)[0])
|
|
||||||
case "json":
|
case "json":
|
||||||
return rune([]byte(JSON_LEAD)[0])
|
return rune([]byte(JSON_LEAD)[0])
|
||||||
default:
|
default:
|
||||||
|
|
25
parser/frontmatter_test.go
Normal file
25
parser/frontmatter_test.go
Normal file
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue