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

Function TestExpireStructure_EXPIRE

structure/expiring_key_test.go:22–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20}
21
22func TestExpireStructure_EXPIRE(t *testing.T) {
23 expire, _ := initExpire()
24 defer expire.db.Close()
25
26 key := "test_key"
27 seconds := int64(2)
28
29 // Test EXPIRE function
30 expireErr = expire.EXPIRE(key, seconds)
31 assert.Nil(t, expireErr)
32
33 // Wait for the key to expire
34 time.Sleep(time.Second * time.Duration(seconds+1))
35
36 // Check if the key has expired
37 ttl, err := expire.TTL(key)
38 assert.Nil(t, err)
39 assert.Equal(t, int64(-2), ttl) // -2 indicates that the key does not exist
40}
41
42func TestExpireStructure_PEXPIRE(t *testing.T) {
43 expire, _ := initExpire()

Callers

nothing calls this directly

Calls 4

initExpireFunction · 0.85
EXPIREMethod · 0.80
CloseMethod · 0.65
TTLMethod · 0.65

Tested by

no test coverage detected