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

Function TestClassifyGHAPIError

pkg/cli/checks_command_test.go:395–475  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

393}
394
395func TestClassifyGHAPIError(t *testing.T) {
396 tests := []struct {
397 name string
398 exitCode int
399 stderr string
400 prNumber string
401 repo string
402 msgContains []string
403 }{
404 {
405 name: "404 not found uses current repository by default",
406 exitCode: 1,
407 stderr: "HTTP 404: Not Found",
408 prNumber: "42",
409 msgContains: []string{
410 "not found",
411 "#42",
412 "current repository",
413 },
414 },
415 {
416 name: "404 not found includes explicit repository",
417 exitCode: 1,
418 stderr: "HTTP 404: Not Found",
419 prNumber: "99",
420 repo: "myorg/myrepo",
421 msgContains: []string{
422 "myorg/myrepo",
423 },
424 },
425 {
426 name: "403 forbidden is classified as auth failure",
427 exitCode: 1,
428 stderr: "HTTP 403: Forbidden",
429 prNumber: "42",
430 msgContains: []string{
431 "authentication failed",
432 "gh auth login",
433 },
434 },
435 {
436 name: "401 unauthorized is classified as auth failure",
437 exitCode: 1,
438 stderr: "HTTP 401: Unauthorized (Bad credentials)",
439 prNumber: "42",
440 msgContains: []string{
441 "authentication failed",
442 },
443 },
444 {
445 name: "bad credentials is classified as auth failure",
446 exitCode: 1,
447 stderr: "Bad credentials",
448 prNumber: "42",
449 msgContains: []string{
450 "authentication failed",
451 },
452 },

Callers

nothing calls this directly

Calls 3

classifyGHAPIErrorFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected