summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/templates/tplcontext_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/templates/tplcontext_test.go')
-rw-r--r--modules/caddyhttp/templates/tplcontext_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/caddyhttp/templates/tplcontext_test.go b/modules/caddyhttp/templates/tplcontext_test.go
index 4c3da03..f90b851 100644
--- a/modules/caddyhttp/templates/tplcontext_test.go
+++ b/modules/caddyhttp/templates/tplcontext_test.go
@@ -290,11 +290,13 @@ func TestSplitFrontMatter(t *testing.T) {
for i, test := range []struct {
input string
expect string
+ body string
}{
{
// yaml with windows newline
input: "---\r\ntitle: Welcome\r\n---\r\n# Test\\r\\n",
expect: `Welcome`,
+ body: "\r\n# Test\\r\\n",
},
{
// yaml
@@ -303,6 +305,16 @@ title: Welcome
---
### Test`,
expect: `Welcome`,
+ body: "\n### Test",
+ },
+ {
+ // yaml with dots for closer
+ input: `---
+title: Welcome
+...
+### Test`,
+ expect: `Welcome`,
+ body: "\n### Test",
},
{
// toml
@@ -311,6 +323,7 @@ title = "Welcome"
+++
### Test`,
expect: `Welcome`,
+ body: "\n### Test",
},
{
// json
@@ -319,12 +332,16 @@ title = "Welcome"
}
### Test`,
expect: `Welcome`,
+ body: "\n### Test",
},
} {
result, _ := context.funcSplitFrontMatter(test.input)
if result.Meta["title"] != test.expect {
t.Errorf("Test %d: Expected %s, found %s. Input was SplitFrontMatter(%s)", i, test.expect, result.Meta["title"], test.input)
}
+ if result.Body != test.body {
+ t.Errorf("Test %d: Expected body %s, found %s. Input was SplitFrontMatter(%s)", i, test.body, result.Body, test.input)
+ }
}
}