TestFormatCompilerMessage tests the formatCompilerMessage helper function
(t *testing.T)
| 138 | |
| 139 | // TestFormatCompilerMessage tests the formatCompilerMessage helper function |
| 140 | func TestFormatCompilerMessage(t *testing.T) { |
| 141 | tests := []struct { |
| 142 | name string |
| 143 | filePath string |
| 144 | msgType string |
| 145 | message string |
| 146 | wantContain []string |
| 147 | }{ |
| 148 | { |
| 149 | name: "warning message", |
| 150 | filePath: "/path/to/workflow.md", |
| 151 | msgType: "warning", |
| 152 | message: "container image validation failed", |
| 153 | wantContain: []string{ |
| 154 | "/path/to/workflow.md", |
| 155 | "warning", |
| 156 | "container image validation failed", |
| 157 | }, |
| 158 | }, |
| 159 | { |
| 160 | name: "error message as string", |
| 161 | filePath: "test.md", |
| 162 | msgType: "error", |
| 163 | message: "validation error", |
| 164 | wantContain: []string{ |
| 165 | "test.md", |
| 166 | "error", |
| 167 | "validation error", |
| 168 | }, |
| 169 | }, |
| 170 | } |
| 171 | |
| 172 | for _, tt := range tests { |
| 173 | t.Run(tt.name, func(t *testing.T) { |
| 174 | msg := formatCompilerMessage(tt.filePath, tt.msgType, tt.message) |
| 175 | |
| 176 | for _, want := range tt.wantContain { |
| 177 | assert.Contains(t, msg, want, "Message should contain: %s", want) |
| 178 | } |
| 179 | }) |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | // TestFormatCompilerError_ErrorWrapping verifies that error wrapping preserves error chains |
| 184 | func TestFormatCompilerError_ErrorWrapping(t *testing.T) { |
nothing calls this directly
no test coverage detected