template: add test for custom function

Signed-off-by: Tw <tw19881113@gmail.com>
This commit is contained in:
Tw
2017-04-18 22:49:20 +08:00
parent f28a159b72
commit 790c842fad
4 changed files with 12 additions and 3 deletions

View File

@ -72,8 +72,16 @@ func TestInclude(t *testing.T) {
shouldErr: true,
expectedErrorContent: `type httpserver.Context`,
},
// Test 4 - all good, with custom function
{
fileContent: `hello {{ caddy }}`,
expectedContent: "hello caddy",
shouldErr: false,
expectedErrorContent: "",
},
}
TemplateFuncs["caddy"] = func() string { return "caddy" }
for i, test := range tests {
testPrefix := getTestPrefix(i)