Fix keylock after patch
This commit is contained in:
parent
669faec71c
commit
79d09955a2
1 changed files with 10 additions and 10 deletions
|
@ -25,24 +25,24 @@ func TestKeyLock_Simple(t *testing.T) {
|
||||||
|
|
||||||
l := keylock.New()
|
l := keylock.New()
|
||||||
|
|
||||||
locked, unlock := l.LockKeys([]string{"a", "b"}, nil)
|
canceled, unlock := l.LockKeys([]string{"a", "b"}, nil)
|
||||||
require.True(t, locked)
|
require.False(t, canceled)
|
||||||
|
|
||||||
locked, _ = l.LockKeys([]string{"", "b", "c"}, timeout(time.Millisecond*10))
|
canceled, _ = l.LockKeys([]string{"", "b", "c"}, timeout(time.Millisecond*10))
|
||||||
require.False(t, locked)
|
require.True(t, canceled)
|
||||||
|
|
||||||
unlock()
|
unlock()
|
||||||
|
|
||||||
locked, _ = l.LockKeys([]string{"", "b", "c"}, nil)
|
canceled, _ = l.LockKeys([]string{"", "b", "c"}, nil)
|
||||||
require.True(t, locked)
|
require.False(t, canceled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestKeyLock_Progress(t *testing.T) {
|
func TestKeyLock_Progress(t *testing.T) {
|
||||||
defer goleak.VerifyNone(t)
|
defer goleak.VerifyNone(t)
|
||||||
l := keylock.New()
|
l := keylock.New()
|
||||||
|
|
||||||
locked, unlock := l.LockKeys([]string{"a", "b"}, nil)
|
canceled, unlock := l.LockKeys([]string{"a", "b"}, nil)
|
||||||
require.True(t, locked)
|
require.False(t, canceled)
|
||||||
defer unlock()
|
defer unlock()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -50,8 +50,8 @@ func TestKeyLock_Progress(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
time.Sleep(time.Millisecond * 10)
|
time.Sleep(time.Millisecond * 10)
|
||||||
locked, _ = l.LockKeys([]string{"d"}, nil)
|
canceled, _ = l.LockKeys([]string{"d"}, nil)
|
||||||
require.True(t, locked)
|
require.False(t, canceled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestKeyLock_DeadlockFree(t *testing.T) {
|
func TestKeyLock_DeadlockFree(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue