Skip to content

Commit cf504ad

Browse files
authored
test(cache): skip redis cache tests when connection fails (#1457)
1 parent 6623850 commit cf504ad

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/Integration/Cache/RedisCacheTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Tempest\KeyValue\Redis\Config\RedisConfig;
99
use Tempest\KeyValue\Redis\PhpRedisClient;
1010
use Tempest\KeyValue\Redis\PredisClient;
11-
use Tempest\KeyValue\Redis\Redis;
1211
use Tests\Tempest\Integration\FrameworkIntegrationTestCase;
1312

1413
final class RedisCacheTest extends FrameworkIntegrationTestCase
@@ -37,6 +36,12 @@ public function test_php_redis_cache(): void
3736
),
3837
);
3938

39+
try {
40+
$redis->connect();
41+
} catch (\Throwable) {
42+
$this->markTestSkipped('Could not connect to Redis.');
43+
}
44+
4045
$cache = new GenericCache(new RedisAdapter($redis->getClient()));
4146

4247
$cache->put('key', 'value');
@@ -59,6 +64,12 @@ public function test_predis_cache(): void
5964
options: ['prefix' => 'tempest_test:'],
6065
));
6166

67+
try {
68+
$redis->connect();
69+
} catch (\Throwable) {
70+
$this->markTestSkipped('Could not connect to Redis.');
71+
}
72+
6273
$cache = new GenericCache(new RedisAdapter($redis->getClient()));
6374

6475
$cache->put('key', 'value');

0 commit comments

Comments
 (0)