Skip to content

Commit a447d14

Browse files
committed
为 CI 配置添加 Redis 服务支持,并在 RedisDriver 测试中修复控制台错误输出的处理逻辑
1 parent 5183d0d commit a447d14

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212
timeout-minutes: 15
13+
services:
14+
redis:
15+
image: redis
16+
ports:
17+
- 6379:6379
18+
options: >-
19+
--health-cmd "redis-cli ping"
20+
--health-interval 10s
21+
--health-timeout 5s
22+
--health-retries 5
1323
strategy:
1424
matrix:
1525
node-version: [18.x, 20.x]

packages/drivers/redis/test/index.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ describe('RedisDriver', () => {
1313

1414
beforeAll(async () => {
1515
let d: RedisDriver | undefined;
16+
// Suppress console.error solely for the connection probe to avoid noise
17+
// when Redis is intentionaly missing (e.g. in some local envs)
18+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
19+
1620
// Skip tests if Redis is not available
1721
try {
1822
d = new RedisDriver({
@@ -31,6 +35,9 @@ describe('RedisDriver', () => {
3135
// Ignore disconnect error
3236
}
3337
}
38+
} finally {
39+
// Restore console.error
40+
consoleErrorSpy.mockRestore();
3441
}
3542
});
3643

0 commit comments

Comments
 (0)