MCPcopy Create free account
hub / github.com/github/gh-aw / TestFormatErrorMessage

Function TestFormatErrorMessage

pkg/console/console_formatting_test.go:242–285  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

240}
241
242func TestFormatErrorMessage(t *testing.T) {
243 tests := []struct {
244 name string
245 message string
246 expected string
247 }{
248 {
249 name: "simple error",
250 message: "File not found",
251 expected: "File not found",
252 },
253 {
254 name: "detailed error",
255 message: "failed to compile workflow: invalid syntax at line 15",
256 expected: "failed to compile workflow: invalid syntax at line 15",
257 },
258 {
259 name: "empty error message",
260 message: "",
261 expected: "",
262 },
263 {
264 name: "error with code",
265 message: "exit code 1: command failed",
266 expected: "exit code 1: command failed",
267 },
268 }
269
270 for _, tt := range tests {
271 t.Run(tt.name, func(t *testing.T) {
272 result := FormatErrorMessage(tt.message)
273
274 // Should contain the X emoji prefix
275 if !strings.Contains(result, "✗") {
276 t.Errorf("FormatErrorMessage() should contain ✗ prefix")
277 }
278
279 // Should contain the error message text
280 if !strings.Contains(result, tt.expected) {
281 t.Errorf("FormatErrorMessage() = %v, should contain %v", result, tt.expected)
282 }
283 })
284 }
285}
286
287func TestFormatSectionHeader(t *testing.T) {
288 tests := []struct {

Callers

nothing calls this directly

Calls 3

FormatErrorMessageFunction · 0.70
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected