MCPcopy Index your code
hub / github.com/cli/cli / TestTokenRunSecureStorage

Function TestTokenRunSecureStorage

pkg/cmd/auth/token/token_test.go:193–274  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

191}
192
193func TestTokenRunSecureStorage(t *testing.T) {
194 tests := []struct {
195 name string
196 opts TokenOptions
197 cfgStubs func(*testing.T, gh.Config)
198 wantStdout string
199 wantErr bool
200 wantErrMsg string
201 }{
202 {
203 name: "token",
204 opts: TokenOptions{},
205 cfgStubs: func(t *testing.T, cfg gh.Config) {
206 login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", true)
207 },
208 wantStdout: "gho_ABCDEFG\n",
209 },
210 {
211 name: "token by hostname",
212 opts: TokenOptions{
213 Hostname: "mycompany.com",
214 },
215 cfgStubs: func(t *testing.T, cfg gh.Config) {
216 login(t, cfg, "mycompany.com", "test-user", "gho_1234567", "https", true)
217 },
218 wantStdout: "gho_1234567\n",
219 },
220 {
221 name: "no token",
222 opts: TokenOptions{},
223 wantErr: true,
224 wantErrMsg: "no oauth token found for github.com",
225 },
226 {
227 name: "no token for hostname user",
228 opts: TokenOptions{
229 Hostname: "ghe.io",
230 Username: "test-user",
231 },
232 wantErr: true,
233 wantErrMsg: "no oauth token found for ghe.io account test-user",
234 },
235 {
236 name: "token for user",
237 opts: TokenOptions{
238 Hostname: "github.com",
239 Username: "test-user",
240 },
241 cfgStubs: func(t *testing.T, cfg gh.Config) {
242 login(t, cfg, "github.com", "test-user", "gho_ABCDEFG", "https", true)
243 login(t, cfg, "github.com", "test-user-2", "gho_1234567", "https", true)
244 },
245 wantStdout: "gho_ABCDEFG\n",
246 },
247 }
248
249 for _, tt := range tests {
250 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 8

TestFunction · 0.92
NewIsolatedTestConfigFunction · 0.92
tokenRunFunction · 0.85
EqualMethod · 0.80
loginFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected