MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestListStructure_TTL

Function TestListStructure_TTL

structure/list_test.go:24–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22}
23
24func TestListStructure_TTL(t *testing.T) {
25 list, _ := initList()
26 defer list.db.Clean()
27
28 err := list.LPush("2", "123123", 2)
29 assert.Nil(t, err)
30
31 ttl, err := list.TTL("2")
32 assert.Nil(t, err)
33 assert.Equal(t, ttl, int64(2))
34
35 time.Sleep(1 * time.Second)
36 ttl, err = list.TTL("2")
37 assert.Nil(t, err)
38 assert.Equal(t, ttl, int64(1))
39
40 time.Sleep(2 * time.Second)
41 ttl, err = list.TTL("1")
42 assert.NotNil(t, err)
43 assert.Equal(t, ttl, int64(-1))
44
45 err = list.LPush("1", "123123", 0)
46 assert.Nil(t, err)
47
48 ttl1, err := list.TTL("1")
49 assert.Nil(t, err)
50 assert.Equal(t, ttl1, int64(0))
51}
52
53func TestListStructure_Size(t *testing.T) {
54 list, _ := initList()

Callers

nothing calls this directly

Calls 4

initListFunction · 0.85
LPushMethod · 0.65
TTLMethod · 0.65
CleanMethod · 0.45

Tested by

no test coverage detected