(t *testing.T)
| 20 | } |
| 21 | |
| 22 | func 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 | |
| 42 | func TestExpireStructure_PEXPIRE(t *testing.T) { |
| 43 | expire, _ := initExpire() |
nothing calls this directly
no test coverage detected