MCPcopy Create free account
hub / github.com/ProspectOne/perfops-cli / TestChkRunError

Function TestChkRunError

cmd/root_test.go:161–178  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159func (e *argError) ArgName() string { return e.name }
160
161func TestChkRunError(t *testing.T) {
162 testCases := map[string]struct {
163 err error
164 exp error
165 }{
166 "Param error": {&argError{"flag"}, errors.New("pflag: help requested")},
167 "401": {&unauthedError{}, errors.New("The API token was declined. Please correct it or do not send a token to use the free plan.")},
168 "Generic error": {errors.New("meep"), errors.New("meep")},
169 "No error": {nil, nil},
170 }
171 for name, tc := range testCases {
172 t.Run(name, func(t *testing.T) {
173 if got, exp := chkRunError(tc.err), tc.exp; !cmpError(got, exp) {
174 t.Fatalf("expected %v; got %v", exp, got)
175 }
176 })
177 }
178}
179
180func TestInvalidArgHelp(t *testing.T) {
181 var fo string

Callers

nothing calls this directly

Calls 2

chkRunErrorFunction · 0.85
cmpErrorFunction · 0.70

Tested by

no test coverage detected