MCPcopy
hub / github.com/kopia/kopia / TestInternalMap

Function TestInternalMap

internal/bigmap/bigmap_internal_test.go:16–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestInternalMap(t *testing.T) {
17 ctx := testlogging.Context(t)
18
19 impl, err := newInternalMap(ctx)
20 require.NoError(t, err)
21
22 defer impl.Close(ctx)
23
24 key1 := []byte("key1")
25 key2 := []byte("longerkey2")
26 val1 := []byte("val1")
27 val2 := []byte("val2")
28
29 v, ok := impl.Get(nil, key1)
30 require.Nil(t, v)
31 require.False(t, ok)
32
33 impl.PutIfAbsent(ctx, key1, val1)
34
35 v, ok = impl.Get(nil, key1)
36 require.True(t, ok)
37 require.Equal(t, val1, v)
38
39 v, ok = impl.Get(nil, key2)
40 require.Nil(t, v)
41 require.False(t, ok)
42
43 impl.PutIfAbsent(ctx, key2, val2)
44
45 v, ok = impl.Get(nil, key2)
46 require.True(t, ok)
47 require.Equal(t, val2, v)
48
49 v, ok = impl.Get(nil, key1)
50 require.True(t, ok)
51 require.Equal(t, val1, v)
52}
53
54func TestGrowingMap(t *testing.T) {
55 ctx := testlogging.Context(t)

Callers

nothing calls this directly

Calls 6

ContextFunction · 0.92
newInternalMapFunction · 0.85
EqualMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.65
PutIfAbsentMethod · 0.45

Tested by

no test coverage detected