Skip to content
Browse files

[tests] TTL and PTTL return -2 on non existing keys in Redis >= 2.8.

  • Loading branch information...
1 parent 46920c9 commit ac01c1a17fa66b1f7133ae3deb2589793796ffb7 @nrk committed Nov 21, 2012
Showing with 12 additions and 8 deletions.
  1. +6 −4 tests/Predis/Command/KeyPreciseTimeToLiveTest.php
  2. +6 −4 tests/Predis/Command/KeyTimeToLiveTest.php
View
10 tests/Predis/Command/KeyPreciseTimeToLiveTest.php
@@ -89,21 +89,23 @@ public function testReturnsTTL()
/**
* @group connected
*/
- public function testReturnsLessThanZeroOnNonExistingKeys()
+ public function testReturnsLessThanZeroOnNonExpiringKeys()
{
$redis = $this->getClient();
+ $redis->set('foo', 'bar');
$this->assertSame(-1, $redis->pttl('foo'));
}
/**
* @group connected
+ * @todo PTTL changed in Redis >= 2.8 to return -2 on non existing keys, we
+ * should handle this case with a better solution than the current one.
*/
- public function testReturnsLessThanZeroOnNonExpiringKeys()
+ public function testReturnsLessThanZeroOnNonExistingKeys()
{
$redis = $this->getClient();
- $redis->set('foo', 'bar');
- $this->assertSame(-1, $redis->pttl('foo'));
+ $this->assertLessThanOrEqual(-1, $redis->pttl('foo'));
}
}
View
10 tests/Predis/Command/KeyTimeToLiveTest.php
@@ -89,21 +89,23 @@ public function testReturnsTTL()
/**
* @group connected
*/
- public function testReturnsLessThanZeroOnNonExistingKeys()
+ public function testReturnsLessThanZeroOnNonExpiringKeys()
{
$redis = $this->getClient();
+ $redis->set('foo', 'bar');
$this->assertSame(-1, $redis->ttl('foo'));
}
/**
* @group connected
+ * @todo TTL changed in Redis >= 2.8 to return -2 on non existing keys, we
+ * should handle this case with a better solution than the current one.
*/
- public function testReturnsLessThanZeroOnNonExpiringKeys()
+ public function testReturnsLessThanZeroOnNonExistingKeys()
{
$redis = $this->getClient();
- $redis->set('foo', 'bar');
- $this->assertSame(-1, $redis->ttl('foo'));
+ $this->assertLessThanOrEqual(-1, $redis->ttl('foo'));
}
}

0 comments on commit ac01c1a

Please sign in to comment.
Something went wrong with that request. Please try again.