(t *testing.T)
| 146 | } |
| 147 | |
| 148 | func 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 | } |