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

Function TestLockTimesOutUnderContention

internal/flock/flock_test.go:148–160  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestLockTimesOutUnderContention(t *testing.T) {
149 lockPath := filepath.Join(t.TempDir(), "held.lock")
150
151 _, unlock, err := flock.TryLock(lockPath)
152 require.NoError(t, err)
153 defer unlock()
154
155 ctx, cancel := context.WithTimeout(t.Context(), 1*time.Millisecond) // duration is not important
156 defer cancel()
157
158 _, _, err = flock.Lock(ctx, lockPath)
159 require.ErrorIs(t, err, flock.ErrTimeout)
160}

Callers

nothing calls this directly

Calls 3

TryLockFunction · 0.92
LockFunction · 0.92
JoinMethod · 0.80

Tested by

no test coverage detected