(t *testing.T)
| 100 | } |
| 101 | |
| 102 | func TestExpireStructure_TTL(t *testing.T) { |
| 103 | expire, _ := initExpire() |
| 104 | defer expire.db.Close() |
| 105 | |
| 106 | key := "test_key" |
| 107 | seconds := int64(2) |
| 108 | |
| 109 | // Test TTL function with an existing key |
| 110 | expire.EXPIRE(key, seconds) |
| 111 | ttl, err := expire.TTL(key) |
| 112 | assert.Nil(t, err) |
| 113 | assert.True(t, ttl > 0) // TTL should be positive |
| 114 | |
| 115 | // Test TTL function with a non-existing key |
| 116 | ttl, err = expire.TTL("non_existing_key") |
| 117 | assert.Nil(t, err) |
| 118 | assert.Equal(t, int64(-2), ttl) // -2 indicates that the key does not exist |
| 119 | } |
| 120 | |
| 121 | func TestExpireStructure_PTTL(t *testing.T) { |
| 122 | expire, _ := initExpire() |
nothing calls this directly
no test coverage detected