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

Function TestLoginAcquiresRefreshLock

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

Source from the content-addressed store, hash-verified

577}
578
579func TestLoginAcquiresRefreshLock(t *testing.T) {
580 // Login must run under the same lock the refresh path uses so it serializes against an in-flight refresh and wins
581 // either ordering. Pin that it acquires and releases the shared refresh lock; without the fix Login mutates the
582 // config without ever touching the lock and this fails.
583 authCfg := newTestAuthConfig(t)
584
585 var locked, unlocked bool
586 authCfg.acquireRefreshLock = func(ctx context.Context, path string) (func(), error) {
587 locked = true
588 return func() { unlocked = true }, nil
589 }
590
591 _, err := authCfg.Login("github.com", "test-user", "gho_token", "https", false)
592 require.NoError(t, err)
593 require.True(t, locked, "login must acquire the shared refresh lock")
594 require.True(t, unlocked, "login must release the shared refresh lock")
595}
596
597func TestLoginProceedsWhenRefreshLockCannotBeAcquired(t *testing.T) {
598 // 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