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

Function TestLoadTemplates

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

Source from the content-addressed store, hash-verified

117var testFiles embed.FS
118
119func TestLoadTemplates(t *testing.T) {
120 // Load templates from the embedded filesystem
121 err := LoadTemplates(testFiles)
122 if err != nil {
123 t.Fatalf("Failed to load templates from embedded filesystem: %v", err)
124 }
125
126 // Check if the template was loaded correctly
127 templateFile := "test.tmpl"
128 tmpl, ok := templates[templateFile]
129 if !ok {
130 t.Fatalf("Template %s not found in loaded templates", templateFile)
131 }
132
133 // Process the loaded template
134 data := Data{"Name": "World"}
135 var buf bytes.Buffer
136 err = tmpl.Execute(&buf, data)
137 if err != nil {
138 t.Fatalf("Failed to execute loaded template: %v", err)
139 }
140
141 // Check the output
142 expected := "Hello, World!"
143 if buf.String() != expected {
144 t.Errorf("Unexpected output. Got: %v, Want: %v", buf.String(), expected)
145 }
146}

Callers

nothing calls this directly

Calls 2

LoadTemplatesFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected