Commit f7e3ed13 authored by Makpoc's avatar Makpoc

TestInclude 2 should fail. Update test data and fix error checking

parent 71c4962f
...@@ -46,7 +46,7 @@ func TestInclude(t *testing.T) { ...@@ -46,7 +46,7 @@ func TestInclude(t *testing.T) {
{ {
fileContent: `str1 {{ .InvalidField }} str2`, fileContent: `str1 {{ .InvalidField }} str2`,
expectedContent: "", expectedContent: "",
shouldErr: false, shouldErr: true,
expectedErrorContent: `InvalidField is not a field of struct type middleware.Context`, expectedErrorContent: `InvalidField is not a field of struct type middleware.Context`,
}, },
} }
...@@ -62,6 +62,9 @@ func TestInclude(t *testing.T) { ...@@ -62,6 +62,9 @@ func TestInclude(t *testing.T) {
content, err := context.Include(inputFilename) content, err := context.Include(inputFilename)
if err != nil { if err != nil {
if !test.shouldErr {
t.Errorf(testPrefix+"Expected no error, found [%s]", test.expectedErrorContent, err.Error())
}
if !strings.Contains(err.Error(), test.expectedErrorContent) { if !strings.Contains(err.Error(), test.expectedErrorContent) {
t.Errorf(testPrefix+"Expected error content [%s], found [%s]", test.expectedErrorContent, err.Error()) t.Errorf(testPrefix+"Expected error content [%s], found [%s]", test.expectedErrorContent, err.Error())
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment