MCPcopy Index your code
hub / github.com/kopia/kopia / TestMutexMap_ExclusiveLock

Function TestMutexMap_ExclusiveLock

internal/cache/mutex_map_test.go:9–27  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestMutexMap_ExclusiveLock(t *testing.T) {
10 var m mutexMap
11
12 require.Empty(t, m.entries)
13 m.exclusiveLock("foo")
14 require.Len(t, m.entries, 1)
15 require.False(t, m.tryExclusiveLock("foo"))
16 require.True(t, m.tryExclusiveLock("bar"))
17 require.False(t, m.trySharedLock("bar"))
18 require.Len(t, m.entries, 2)
19 m.exclusiveUnlock("foo")
20 require.Len(t, m.entries, 1)
21 require.True(t, m.tryExclusiveLock("foo"))
22 require.Len(t, m.entries, 2)
23 m.exclusiveUnlock("foo")
24 require.Len(t, m.entries, 1)
25 m.exclusiveUnlock("bar")
26 require.Empty(t, m.entries)
27}
28
29func TestMutexMap_SharedLock(t *testing.T) {
30 var m mutexMap

Callers

nothing calls this directly

Calls 5

exclusiveLockMethod · 0.95
tryExclusiveLockMethod · 0.95
trySharedLockMethod · 0.95
exclusiveUnlockMethod · 0.95
LenMethod · 0.45

Tested by

no test coverage detected