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

Function TestExpireStructure_EXPIREAT

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

Source from the content-addressed store, hash-verified

60}
61
62func TestExpireStructure_EXPIREAT(t *testing.T) {
63 expire, _ := initExpire()
64 defer expire.db.Close()
65
66 key := "test_key"
67 timestamp := time.Now().Add(time.Second * 2).Unix()
68
69 // Test EXPIREAT function
70 expireErr = expire.EXPIREAT(key, timestamp)
71 assert.Nil(t, expireErr)
72
73 // Wait for the key to expire
74 time.Sleep(time.Second * 3)
75
76 // Check if the key has expired
77 ttl, err := expire.TTL(key)
78 assert.Nil(t, err)
79 assert.Equal(t, int64(-2), ttl) // -2 indicates that the key does not exist
80}
81
82func TestExpireStructure_PEXPIREAT(t *testing.T) {
83 expire, _ := initExpire()

Callers

nothing calls this directly

Calls 5

initExpireFunction · 0.85
AddMethod · 0.80
EXPIREATMethod · 0.80
CloseMethod · 0.65
TTLMethod · 0.65

Tested by

no test coverage detected