(
title: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- variance markers for client generics
fn: (proxiedClient: RedisClientType<any, any, any, any, any>, proxy: RedisProxy) => unknown,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- variance markers for client generics
options: ClientTestOptions<any, any, any, any, any>
)
| 577 | } |
| 578 | |
| 579 | testWithProxiedClient( |
| 580 | title: string, |
| 581 | // eslint-disable-next-line @typescript-eslint/no-explicit-any -- variance markers for client generics |
| 582 | fn: (proxiedClient: RedisClientType<any, any, any, any, any>, proxy: RedisProxy) => unknown, |
| 583 | // eslint-disable-next-line @typescript-eslint/no-explicit-any -- variance markers for client generics |
| 584 | options: ClientTestOptions<any, any, any, any, any> |
| 585 | ) { |
| 586 | |
| 587 | this.testWithClient(title, async (client) => { |
| 588 | const freePort = await getFreePortNumber() |
| 589 | const socketOptions = client?.options?.socket; |
| 590 | const proxy = new RedisProxy({ |
| 591 | listenHost: '127.0.0.1', |
| 592 | listenPort: freePort, |
| 593 | // @ts-expect-error -- proxy tests target TCP-only socket options |
| 594 | targetPort: socketOptions.port, |
| 595 | // @ts-expect-error -- proxy tests target TCP-only socket options |
| 596 | targetHost: socketOptions.host ?? '127.0.0.1', |
| 597 | enableLogging: true |
| 598 | }); |
| 599 | |
| 600 | await proxy.start(); |
| 601 | const proxyClient = client.duplicate({ |
| 602 | socket: { |
| 603 | port: proxy.config.listenPort, |
| 604 | host: proxy.config.listenHost |
| 605 | }, |
| 606 | }); |
| 607 | |
| 608 | await proxyClient.connect(); |
| 609 | |
| 610 | try { |
| 611 | await fn(proxyClient, proxy); |
| 612 | } finally { |
| 613 | await proxyClient.destroy(); |
| 614 | await proxy.stop() |
| 615 | } |
| 616 | }, options); |
| 617 | } |
| 618 | testWithClientSentinel< |
| 619 | M extends RedisModules = {}, |
| 620 | F extends RedisFunctions = {}, |
no test coverage detected