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

Function TestLoginAcquiresRefreshLock

internal/config/refreshable_test.go:418–434  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

416}
417
418func TestLoginAcquiresRefreshLock(t *testing.T) {
419 // Login must run under the same lock the refresh path uses so it serializes against an in-flight refresh and wins
420 // either ordering. Pin that it acquires and releases the shared refresh lock; without the fix Login mutates the
421 // config without ever touching the lock and this fails.
422 authCfg := newTestAuthConfig(t)
423
424 var locked, unlocked bool
425 authCfg.acquireRefreshLock = func(ctx context.Context, path string) (func(), error) {
426 locked = true
427 return func() { unlocked = true }, nil
428 }
429
430 _, err := authCfg.Login("github.com", "test-user", "gho_token", "https", false)
431 require.NoError(t, err)
432 require.True(t, locked, "login must acquire the shared refresh lock")
433 require.True(t, unlocked, "login must release the shared refresh lock")
434}
435
436func TestLoginProceedsWhenRefreshLockCannotBeAcquired(t *testing.T) {
437 // The cross-process lock is best effort: a filesystem without advisory locking (or a peer holding the lock past

Callers

nothing calls this directly

Calls 2

newTestAuthConfigFunction · 0.85
LoginMethod · 0.65

Tested by

no test coverage detected