MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestNewIdKeyMap

Function TestNewIdKeyMap

internal/utils/expires/id_key_map_test.go:12–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestNewIdKeyMap(t *testing.T) {
13 var a = assert.NewAssertion(t)
14
15 var m = expires.NewIdKeyMap()
16 m.Add(1, "1")
17 m.Add(1, "2")
18 m.Add(100, "100")
19 logs.PrintAsJSON(m.IdKeys(), t)
20 logs.PrintAsJSON(m.KeyIds(), t)
21
22 {
23 k, ok := m.Key(1)
24 a.IsTrue(ok)
25 a.IsTrue(k == "2")
26 }
27
28 {
29 _, ok := m.Key(2)
30 a.IsFalse(ok)
31 }
32
33 m.DeleteKey("2")
34
35 {
36 _, ok := m.Key(1)
37 a.IsFalse(ok)
38 }
39
40 logs.PrintAsJSON(m.IdKeys(), t)
41 logs.PrintAsJSON(m.KeyIds(), t)
42
43 m.DeleteId(100)
44
45 logs.PrintAsJSON(m.IdKeys(), t)
46 logs.PrintAsJSON(m.KeyIds(), t)
47}

Callers

nothing calls this directly

Calls 7

NewIdKeyMapFunction · 0.92
IdKeysMethod · 0.80
KeyIdsMethod · 0.80
DeleteKeyMethod · 0.80
DeleteIdMethod · 0.80
AddMethod · 0.65
KeyMethod · 0.65

Tested by

no test coverage detected