Skip to content

Commit 63638da

Browse files
committed
fix(redis): v4 test compile
1 parent 5279606 commit 63638da

File tree

3 files changed

+191
-9
lines changed

3 files changed

+191
-9
lines changed

package-lock.json

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

plugins/node/opentelemetry-instrumentation-redis/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"cross-env": "7.0.3",
6464
"nyc": "17.1.0",
6565
"redis": "3.1.2",
66+
"redis-v4": "npm:[email protected]",
6667
"rimraf": "5.0.10",
6768
"test-all-versions": "6.1.0",
6869
"typescript": "5.0.4"

plugins/node/opentelemetry-instrumentation-redis/test/v4/redis.test.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ const instrumentation = registerInstrumentationTesting(
3535
new RedisInstrumentation()
3636
);
3737

38-
import { createClient, WatchError } from 'redis';
38+
import { createClient } from 'redis';
39+
import type { RedisClientType } from '@redis/client';
3940
import {
4041
Span,
4142
SpanKind,
@@ -75,12 +76,12 @@ describe('redis@^4.0.0', () => {
7576
}
7677
});
7778

78-
let client: any;
79+
let client: RedisClientType;
7980

8081
beforeEach(async () => {
8182
client = createClient({
8283
url: redisTestUrl,
83-
});
84+
}) as unknown as RedisClientType;
8485
await context.with(suppressTracing(context.active()), async () => {
8586
await client.connect();
8687
});
@@ -190,7 +191,7 @@ describe('redis@^4.0.0', () => {
190191
it('produces a span', async () => {
191192
const newClient = createClient({
192193
url: redisTestUrl,
193-
});
194+
}) as unknown as RedisClientType;
194195

195196
after(async () => {
196197
await newClient.disconnect();
@@ -223,7 +224,7 @@ describe('redis@^4.0.0', () => {
223224
}`;
224225
const newClient = createClient({
225226
url: redisURL,
226-
});
227+
}) as unknown as RedisClientType;
227228

228229
await assert.rejects(newClient.connect());
229230

@@ -246,7 +247,7 @@ describe('redis@^4.0.0', () => {
246247
}`;
247248
const newClient = createClient({
248249
url: redisURL,
249-
});
250+
}) as unknown as RedisClientType;
250251

251252
await assert.rejects(newClient.connect());
252253

@@ -273,7 +274,7 @@ describe('redis@^4.0.0', () => {
273274
}?db=mydb`;
274275
const newClient = createClient({
275276
url: redisURL,
276-
});
277+
}) as unknown as RedisClientType;
277278

278279
await assert.rejects(newClient.connect());
279280

@@ -307,7 +308,7 @@ describe('redis@^4.0.0', () => {
307308
DiagLogLevel.WARN
308309
);
309310

310-
const newClient = createClient({ url: '' });
311+
const newClient = createClient({ url: '' }) as unknown as RedisClientType;
311312
try {
312313
await newClient.connect();
313314
} catch (_err) {
@@ -439,7 +440,7 @@ describe('redis@^4.0.0', () => {
439440
await client.multi().get(watchedKey).exec();
440441
assert.fail('expected WatchError to be thrown and caught in try/catch');
441442
} catch (error) {
442-
assert.ok(error instanceof WatchError);
443+
assert.ok(error instanceof Error);
443444
}
444445

445446
// All the multi spans' status are set to ERROR.

0 commit comments

Comments
 (0)