MCPcopy Create free account
hub / github.com/CloudyKit/jet / RunJetTestWithTemplate

Function RunJetTestWithTemplate

eval_test.go:119–141  ·  view source on GitHub ↗
(t *testing.T, tt *Template, variables VarMap, context interface{}, testExpected string)

Source from the content-addressed store, hash-verified

117}
118
119func 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
143func TestEvalTextNode(t *testing.T) {
144 RunJetTest(t, nil, nil, "textNode", `hello {*Buddy*} World`, `hello World`)

Callers 1

RunJetTestWithSetFunction · 0.85

Calls 2

ExecuteMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…