MCPcopy Create free account
hub / github.com/cli/cli / TestTokenHasUserCapability

Function TestTokenHasUserCapability

acceptance/user_capability_test.go:131–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

129}
130
131func TestTokenHasUserCapability(t *testing.T) {
132 tests := []struct {
133 token string
134 want bool
135 }{
136 {token: "ghp_token", want: true},
137 {token: "gho_token", want: true},
138 {token: "github_pat_token", want: true},
139 {token: "ghu_token", want: true},
140 {token: "ghs_token", want: false},
141 }
142
143 for _, tt := range tests {
144 t.Run(tt.token[:4], func(t *testing.T) {
145 got, err := tokenHasUserCapability(tt.token)
146 require.NoError(t, err)
147 assert.Equal(t, tt.want, got)
148 })
149 }
150
151 _, err := tokenHasUserCapability("unsupported")
152 assert.EqualError(t, err, "GH_ACCEPTANCE_TOKEN has an unsupported token prefix")
153}
154
155func TestAcceptanceScriptsDeclareUserCapabilityRequirement(t *testing.T) {
156 files, err := filepath.Glob(filepath.Join("testdata", "*", "*.txtar"))

Callers

nothing calls this directly

Calls 3

tokenHasUserCapabilityFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected