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

Function TestIsPermissionError

pkg/cli/audit_test.go:24–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestIsPermissionError(t *testing.T) {
25 tests := []struct {
26 name string
27 err error
28 expected bool
29 }{
30 {
31 name: "Nil error",
32 err: nil,
33 expected: false,
34 },
35 {
36 name: "Authentication required error",
37 err: errors.New("authentication required"),
38 expected: true,
39 },
40 {
41 name: "Exit status 4 error",
42 err: errors.New("exit status 4"),
43 expected: true,
44 },
45 {
46 name: "GitHub CLI authentication error",
47 err: errors.New("GitHub CLI authentication required"),
48 expected: true,
49 },
50 {
51 name: "Permission denied error",
52 err: errors.New("permission denied"),
53 expected: true,
54 },
55 {
56 name: "GH_TOKEN error",
57 err: errors.New("GH_TOKEN environment variable not set"),
58 expected: true,
59 },
60 {
61 name: "Not logged into any GitHub hosts error",
62 err: errors.New("not logged into any GitHub hosts"),
63 expected: true,
64 },
65 {
66 name: "GitHub Actions workflow auth error",
67 err: errors.New("To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable"),
68 expected: true,
69 },
70 {
71 name: "gh auth login message",
72 err: errors.New("run gh auth login to authenticate"),
73 expected: true,
74 },
75 {
76 name: "Other error",
77 err: errors.New("some other error"),
78 expected: false,
79 },
80 }
81

Callers

nothing calls this directly

Calls 3

isPermissionErrorFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected