summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/templates/tplcontext_test.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-12-23 12:56:41 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2019-12-23 12:56:41 -0700
commit82bebfab8a6528f24f23dac99ce5b11efab27761 (patch)
tree70d9d4a15b1475a3d9f01cad9a8f60556f9552cd /modules/caddyhttp/templates/tplcontext_test.go
parentbe3849c2671e74c461e1885d3a15e7e97b967895 (diff)
templates: Change functions, add front matter support, better markdown
Diffstat (limited to 'modules/caddyhttp/templates/tplcontext_test.go')
-rw-r--r--modules/caddyhttp/templates/tplcontext_test.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/caddyhttp/templates/tplcontext_test.go b/modules/caddyhttp/templates/tplcontext_test.go
index d9aab0c..37b6382 100644
--- a/modules/caddyhttp/templates/tplcontext_test.go
+++ b/modules/caddyhttp/templates/tplcontext_test.go
@@ -31,6 +31,7 @@ package templates
import (
"bytes"
"fmt"
+ "html/template"
"io/ioutil"
"net/http"
"os"
@@ -47,17 +48,20 @@ func TestMarkdown(t *testing.T) {
for i, test := range []struct {
body string
- expect string
+ expect template.HTML
}{
{
body: "- str1\n- str2\n",
expect: "<ul>\n<li>str1</li>\n<li>str2</li>\n</ul>\n",
},
} {
- result := string(context.Markdown(test.body))
+ result, err := context.funcMarkdown(test.body)
if result != test.expect {
t.Errorf("Test %d: expected '%s' but got '%s'", i, test.expect, result)
}
+ if err != nil {
+ t.Errorf("Test %d: got error: %v", i, result)
+ }
}
}
@@ -180,7 +184,7 @@ func TestStripHTML(t *testing.T) {
expect: `<h1hi`,
},
} {
- actual := context.StripHTML(test.input)
+ actual := context.funcStripHTML(test.input)
if actual != test.expect {
t.Errorf("Test %d: Expected %s, found %s. Input was StripHTML(%s)", i, test.expect, actual, test.input)
}
@@ -249,7 +253,7 @@ func TestFileListing(t *testing.T) {
// perform test
input := filepath.ToSlash(filepath.Join(filepath.Base(dirPath), test.inputBase))
- actual, err := context.ListFiles(input)
+ actual, err := context.funcListFiles(input)
if err != nil {
if !test.shouldErr {
t.Errorf("Test %d: Expected no error, got: '%s'", i, err)