MCPcopy Create free account
hub / github.com/appleboy/CodeGPT / TestNewTemplateByStringWithCustomVars

Function TestNewTemplateByStringWithCustomVars

util/template_test.go:29–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27}
28
29func TestNewTemplateByStringWithCustomVars(t *testing.T) {
30 data := map[string]any{}
31 vars := ConvertToMap([]string{"Name=John Doe", "Message=Hello"})
32 maps.Copy(data, vars)
33
34 expected := "Hello, John Doe! Hello"
35
36 actual, err := NewTemplateByString("Hello, {{.Name}}! {{.Message}}", data)
37 if err != nil {
38 t.Errorf("Unexpected error: %v", err)
39 }
40
41 if actual != expected {
42 t.Errorf("Expected %q but got %q", expected, actual)
43 }
44}
45
46func TestProcessTemplate(t *testing.T) {
47 // Set up test data

Callers

nothing calls this directly

Calls 2

ConvertToMapFunction · 0.85
NewTemplateByStringFunction · 0.85

Tested by

no test coverage detected