(t *testing.T)
| 117 | var testFiles embed.FS |
| 118 | |
| 119 | func 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 | } |
nothing calls this directly
no test coverage detected