Fix keylock after patch

This commit is contained in:
Fedor Korotkiy 2020-03-16 13:20:09 +03:00
parent 669faec71c
commit 79d09955a2

View file

@ -25,24 +25,24 @@ func TestKeyLock_Simple(t *testing.T) {
l := keylock.New()
locked, unlock := l.LockKeys([]string{"a", "b"}, nil)
require.True(t, locked)
canceled, unlock := l.LockKeys([]string{"a", "b"}, nil)
require.False(t, canceled)
locked, _ = l.LockKeys([]string{"", "b", "c"}, timeout(time.Millisecond*10))
require.False(t, locked)
canceled, _ = l.LockKeys([]string{"", "b", "c"}, timeout(time.Millisecond*10))
require.True(t, canceled)
unlock()
locked, _ = l.LockKeys([]string{"", "b", "c"}, nil)
require.True(t, locked)
canceled, _ = l.LockKeys([]string{"", "b", "c"}, nil)
require.False(t, canceled)
}
func TestKeyLock_Progress(t *testing.T) {
defer goleak.VerifyNone(t)
l := keylock.New()
locked, unlock := l.LockKeys([]string{"a", "b"}, nil)
require.True(t, locked)
canceled, unlock := l.LockKeys([]string{"a", "b"}, nil)
require.False(t, canceled)
defer unlock()
go func() {
@ -50,8 +50,8 @@ func TestKeyLock_Progress(t *testing.T) {
}()
time.Sleep(time.Millisecond * 10)
locked, _ = l.LockKeys([]string{"d"}, nil)
require.True(t, locked)
canceled, _ = l.LockKeys([]string{"d"}, nil)
require.False(t, canceled)
}
func TestKeyLock_DeadlockFree(t *testing.T) {