(t *testing.T)
| 44 | } |
| 45 | |
| 46 | func TestProcessTemplate(t *testing.T) { |
| 47 | // Set up test data |
| 48 | testTemplateName := "foo.tmpl" |
| 49 | testTemplateText := "Hello {{.Name}}!" |
| 50 | testData := Data{"Name": "World"} |
| 51 | |
| 52 | // Parse test template |
| 53 | tmpl, err := template.New(testTemplateName).Parse(testTemplateText) |
| 54 | if err != nil { |
| 55 | t.Errorf("Failed to parse test template: %v", err) |
| 56 | } |
| 57 | |
| 58 | // Add test template to templates map |
| 59 | templates = make(map[string]*template.Template) |
| 60 | templates[testTemplateName] = tmpl |
| 61 | |
| 62 | // Process test template |
| 63 | buf, err := processTemplate(testTemplateName, testData) |
| 64 | if err != nil { |
| 65 | t.Errorf("Failed to process template: %v", err) |
| 66 | } |
| 67 | |
| 68 | // Check the output |
| 69 | expected := "Hello World!" |
| 70 | if buf.String() != expected { |
| 71 | t.Errorf("Unexpected output. Got: %v, Want: %v", buf.String(), expected) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | func TestLoadTemplatesFromDir(t *testing.T) { |
| 76 | // Create a temporary directory for testing |
nothing calls this directly
no test coverage detected