(t *testing.T, tt *Template, variables VarMap, context interface{}, testExpected string)
| 117 | } |
| 118 | |
| 119 | func RunJetTestWithTemplate(t *testing.T, tt *Template, variables VarMap, context interface{}, testExpected string) { |
| 120 | if testing.RunTests(func(pat, str string) (bool, error) { |
| 121 | return true, nil |
| 122 | }, []testing.InternalTest{ |
| 123 | { |
| 124 | Name: fmt.Sprintf("\tJetTest(%s)", tt.Name), |
| 125 | F: func(t *testing.T) { |
| 126 | var buf bytes.Buffer |
| 127 | err := tt.Execute(&buf, variables, context) |
| 128 | if err != nil { |
| 129 | t.Errorf("Eval error: %q executing %s", err.Error(), tt.Name) |
| 130 | return |
| 131 | } |
| 132 | result := strings.ReplaceAll(buf.String(), "\r\n", "\n") |
| 133 | if result != testExpected { |
| 134 | t.Errorf("Result error expected %q got %q on %s", testExpected, result, tt.Name) |
| 135 | } |
| 136 | }, |
| 137 | }, |
| 138 | }) == false { |
| 139 | t.Fail() |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | func TestEvalTextNode(t *testing.T) { |
| 144 | RunJetTest(t, nil, nil, "textNode", `hello {*Buddy*} World`, `hello World`) |
no test coverage detected
searching dependent graphs…