(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func TestExpireStructure_PEXPIRE(t *testing.T) { |
| 43 | expire, _ := initExpire() |
| 44 | defer expire.db.Close() |
| 45 | |
| 46 | key := "test_key" |
| 47 | milliseconds := int64(2000) |
| 48 | |
| 49 | // Test PEXPIRE function |
| 50 | expireErr = expire.PEXPIRE(key, milliseconds) |
| 51 | assert.Nil(t, expireErr) |
| 52 | |
| 53 | // Wait for the key to expire |
| 54 | time.Sleep(time.Millisecond * time.Duration(milliseconds+100)) |
| 55 | |
| 56 | // Check if the key has expired |
| 57 | ttl, err := expire.TTL(key) |
| 58 | assert.Nil(t, err) |
| 59 | assert.Equal(t, int64(-2), ttl) // -2 indicates that the key does not exist |
| 60 | } |
| 61 | |
| 62 | func TestExpireStructure_EXPIREAT(t *testing.T) { |
| 63 | expire, _ := initExpire() |
nothing calls this directly
no test coverage detected