Add test to make sure passed keys are not modified in keylock
This commit is contained in:
parent
e40aa18778
commit
f1997376ee
1 changed files with 14 additions and 0 deletions
|
@ -83,6 +83,20 @@ func TestKeyLock_DeadlockFree(t *testing.T) {
|
|||
wg.Wait()
|
||||
}
|
||||
|
||||
func TestKeyLock_NoMutates(t *testing.T) {
|
||||
defer goleak.VerifyNone(t)
|
||||
l := keylock.New()
|
||||
|
||||
keys := []string{"b", "c", "a"}
|
||||
passedKeys := make([]string, len(keys))
|
||||
copy(passedKeys, keys)
|
||||
|
||||
_, unlock := l.LockKeys(passedKeys, nil)
|
||||
unlock()
|
||||
|
||||
require.Equal(t, keys, passedKeys, "passed keys shouldn't be mutated")
|
||||
}
|
||||
|
||||
func TestKeyLock_SingleKeyStress(t *testing.T) {
|
||||
const (
|
||||
N = 1000
|
||||
|
|
Loading…
Reference in a new issue