(t *testing.T)
| 230 | } |
| 231 | |
| 232 | func TestExpireStructure_EXPIREBYAT(t *testing.T) { |
| 233 | expire, _ := initExpire() |
| 234 | defer expire.db.Close() |
| 235 | |
| 236 | key := "test_key" |
| 237 | timestamp := time.Now().Add(time.Second * 2).Unix() |
| 238 | |
| 239 | // Test EXPIREBYAT function without tag |
| 240 | expireErr = expire.EXPIREBYAT(key, timestamp) |
| 241 | assert.Nil(t, expireErr) |
| 242 | |
| 243 | // Wait for the key to expire |
| 244 | time.Sleep(time.Second * 3) |
| 245 | |
| 246 | // Check if the key has expired |
| 247 | ttl, err := expire.TTL(key) |
| 248 | assert.Nil(t, err) |
| 249 | assert.Equal(t, int64(-2), ttl) // -2 indicates that the key does not exist |
| 250 | |
| 251 | // Test EXPIREBYAT function with tag "ex" |
| 252 | expireErr = expire.EXPIREBYAT(key, timestamp, "ex") |
| 253 | assert.Nil(t, expireErr) |
| 254 | |
| 255 | // Check if the key has expired |
| 256 | ttl, err = expire.TTL(key) |
| 257 | assert.Nil(t, err) |
| 258 | assert.Equal(t, int64(timestamp), ttl) |
| 259 | |
| 260 | // Test EXPIREBYAT function with an invalid tag |
| 261 | expireErr = expire.EXPIREBYAT(key, timestamp, "invalid_tag") |
| 262 | assert.Equal(t, ErrInvalidArgs, expireErr) |
| 263 | } |
| 264 | |
| 265 | func TestExpireStructure_PEXPIREBYAT(t *testing.T) { |
| 266 | expire, _ := initExpire() |
nothing calls this directly
no test coverage detected