Skip to content

Commit 74e4f2d

Browse files
committed
Revert "feat(health-indicator): add Redis client dependency and integration tests"
This reverts commit f2db41c.
1 parent fa205c1 commit 74e4f2d

File tree

3 files changed

+19
-157
lines changed

3 files changed

+19
-157
lines changed

packages/health-indicator/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@
5959
"redis": "^5.0.0"
6060
},
6161
"devDependencies": {
62-
"@nestjs-redis/client": "0.10.1",
6362
"@nestjs/testing": "^11.0.0",
64-
"redis": "^5.0.0",
65-
"supertest": "^7.1.4"
63+
"redis": "^5.0.0"
6664
},
6765
"engines": {
6866
"node": ">=18.0.0",
Lines changed: 18 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import { Controller, Get, Module } from '@nestjs/common';
2-
import {
3-
HealthCheck,
4-
HealthCheckResult,
5-
HealthCheckService,
6-
TerminusModule,
7-
} from '@nestjs/terminus';
1+
import { HealthIndicatorService } from '@nestjs/terminus';
82
import { Test, TestingModule } from '@nestjs/testing';
9-
import { InjectRedis, Redis, RedisModule } from '@nestjs-redis/client';
103
import { createClient } from 'redis';
11-
import request from 'supertest';
124
import { RedisHealthIndicator } from './health.indicator';
5+
import { Redis } from './interfaces';
136

147
// These tests require a running Redis instance
158
const REDIS_URL = process.env.REDIS_URL || 'redis://localhost:6379';
@@ -20,8 +13,22 @@ describe('RedisHealthIndicator Integration Tests', () => {
2013

2114
beforeAll(async () => {
2215
const module: TestingModule = await Test.createTestingModule({
23-
imports: [TerminusModule],
24-
providers: [RedisHealthIndicator],
16+
providers: [
17+
RedisHealthIndicator,
18+
{
19+
provide: HealthIndicatorService,
20+
useValue: {
21+
check: jest.fn().mockReturnValue({
22+
up: jest.fn().mockImplementation((data) => ({
23+
redis: { status: 'up', ...data },
24+
})),
25+
down: jest.fn().mockImplementation((data) => ({
26+
redis: { status: 'down', ...data },
27+
})),
28+
}),
29+
},
30+
},
31+
],
2532
}).compile();
2633

2734
healthIndicator = module.get<RedisHealthIndicator>(RedisHealthIndicator);
@@ -78,66 +85,4 @@ describe('RedisHealthIndicator Integration Tests', () => {
7885
}
7986
}, 15000);
8087
});
81-
82-
describe('Full RedisModule Integration', () => {
83-
it('should integrate with the full RedisModule', async () => {
84-
@Controller('health')
85-
class HealthController {
86-
constructor(
87-
private health: HealthCheckService,
88-
private redis: RedisHealthIndicator,
89-
@InjectRedis() private readonly redisClient: Redis,
90-
) {}
91-
92-
@Get()
93-
@HealthCheck()
94-
check(): Promise<HealthCheckResult> {
95-
return this.health.check([
96-
() => this.redis.isHealthy('redis', { client: this.redisClient }),
97-
]);
98-
}
99-
}
100-
101-
@Module({
102-
imports: [
103-
RedisModule.forRoot({
104-
type: 'client',
105-
options: { url: process.env.REDIS_URL },
106-
}),
107-
TerminusModule,
108-
],
109-
controllers: [HealthController],
110-
providers: [RedisHealthIndicator],
111-
})
112-
class HealthModule {}
113-
114-
@Module({
115-
imports: [HealthModule],
116-
controllers: [],
117-
providers: [],
118-
})
119-
class AppModule {}
120-
121-
const module: TestingModule = await Test.createTestingModule({
122-
imports: [AppModule],
123-
}).compile();
124-
125-
const app = module.createNestApplication();
126-
await app.init();
127-
128-
request(app.getHttpServer())
129-
.get('/health')
130-
.expect(200)
131-
.expect({
132-
data: {
133-
status: 'ok',
134-
info: { redis: { status: 'up' } },
135-
error: {},
136-
details: { redis: { status: 'up' } },
137-
},
138-
});
139-
140-
await app.close();
141-
});
142-
});
14388
});

pnpm-lock.yaml

Lines changed: 0 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)