Scope writer locks to each writer.

Signed-off-by: Niklas Gehlen <niklas@namespacelabs.com>
This commit is contained in:
Niklas Gehlen
2024-10-23 20:39:51 +02:00
parent b291eb802b
commit 2535b187a6
4 changed files with 23 additions and 24 deletions

View File

@@ -24,11 +24,13 @@ import (
)
func TestTryLock(t *testing.T) {
err := tryLock("testref")
assert.NoError(t, err)
defer unlock("testref")
s := &store{locks: map[string]*lock{}}
err = tryLock("testref")
err := s.tryLock("testref")
assert.NoError(t, err)
defer s.unlock("testref")
err = s.tryLock("testref")
require.NotNil(t, err)
assert.Contains(t, err.Error(), "ref testref locked for ")
}