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

Function TestFormatErrorWithSuggestions

pkg/console/console_test.go:96–160  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func TestFormatErrorWithSuggestions(t *testing.T) {
97 tests := []struct {
98 name string
99 message string
100 suggestions []string
101 expected []string
102 }{
103 {
104 name: "error with suggestions",
105 message: "workflow 'test' not found",
106 suggestions: []string{
107 "Run 'gh aw status' to see all available workflows",
108 "Create a new workflow with 'gh aw new test'",
109 "Check for typos in the workflow name",
110 },
111 expected: []string{
112 "✗",
113 "workflow 'test' not found",
114 "Suggestions:",
115 "• Run 'gh aw status' to see all available workflows",
116 "• Create a new workflow with 'gh aw new test'",
117 "• Check for typos in the workflow name",
118 },
119 },
120 {
121 name: "error without suggestions",
122 message: "workflow 'test' not found",
123 suggestions: []string{},
124 expected: []string{
125 "✗",
126 "workflow 'test' not found",
127 },
128 },
129 {
130 name: "error with single suggestion",
131 message: "file not found",
132 suggestions: []string{
133 "Check the file path",
134 },
135 expected: []string{
136 "✗",
137 "file not found",
138 "Suggestions:",
139 "• Check the file path",
140 },
141 },
142 }
143
144 for _, tt := range tests {
145 t.Run(tt.name, func(t *testing.T) {
146 output := FormatErrorWithSuggestions(tt.message, tt.suggestions)
147
148 for _, expected := range tt.expected {
149 if !strings.Contains(output, expected) {
150 t.Errorf("Expected output to contain '%s', but got:\n%s", expected, output)
151 }
152 }
153

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected