Skip to content

Commit

Permalink
Fixed tests after changes made in the Redis adapter.
Browse files Browse the repository at this point in the history
See #74 for more info.
  • Loading branch information
ariasmn committed May 10, 2021
1 parent 161dcad commit d1831bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/Ackintosh/Ganesha/Storage/Adapter/AbstractRedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ public function incrementThrowsException()
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessageRegExp /\AFailed to remove expired elements/
*/
public function loadThrowsExceptionWhenFailedToRunzRemRangeByScore()
public function incrementThrowsExceptionWhenFailedToRunzRemRangeByScore()
{
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('zRemRangeByScore')
->willReturn(false);

$this->createAdapterWithMock($mock)->load($this->service);
$this->createAdapterWithMock($mock)->increment($this->service);
}

/**
Expand All @@ -156,7 +156,7 @@ public function loadThrowsExceptionWhenFailedToRunzCard()
public function loadThrowsException()
{
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('zRemRangeByScore')
$mock->method('zCard')
->willThrowException(new \RedisException('exception test'));

$this->createAdapterWithMock($mock)->load($this->service);
Expand Down
10 changes: 9 additions & 1 deletion tests/Ackintosh/Ganesha/StorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ public function getLastFailureTimeWithSlidingTimeWindow()
getenv('GANESHA_EXAMPLE_REDIS') ? getenv('GANESHA_EXAMPLE_REDIS') : 'localhost'
);
$r->flushAll();
$storage = new Storage(new Redis(($r)), new Ganesha\Storage\StorageKeys(), null);

$redisAdapter = new Redis($r);
$context = new Ganesha\Context(
Ganesha\Strategy\Rate::class,
$redisAdapter,
new Configuration(['timeWindow' => 3])
);
$redisAdapter->setContext($context);
$storage = new Storage($redisAdapter, new Ganesha\Storage\StorageKeys(), null);

$service = 'test';
$storage->incrementFailureCount($service);
Expand Down

0 comments on commit d1831bb

Please sign in to comment.