Skip to content

Commit

Permalink
Add a valid slots table to mock server in tests that expect to be abl…
Browse files Browse the repository at this point in the history
…e to connect using the Cluster client

Signed-off-by: Martin Slota <[email protected]>
  • Loading branch information
martinslota committed Jun 10, 2024
1 parent 0deaeba commit d5d85e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion test/functional/cluster/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,12 @@ describe("cluster:connect", () => {

describe("multiple reconnect", () => {
it("should reconnect after multiple consecutive disconnect(true) are called", (done) => {
new MockServer(30001);
const slotTable = [[0, 16383, ["127.0.0.1", 30001]]];
new MockServer(30001, (argv) => {
if (argv[0] === "cluster" && argv[1] === "SLOTS") {
return slotTable;
}
});
const cluster = new Cluster([{ host: "127.0.0.1", port: "30001" }], {
enableReadyCheck: false,
});
Expand Down
7 changes: 6 additions & 1 deletion test/functional/cluster/disconnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ describe("disconnection", () => {
});

it("should clear all timers on disconnect", (done) => {
const server = new MockServer(30000);
const slotTable = [[0, 16383, ["127.0.0.1", 30000]]];
const server = new MockServer(30000, (argv) => {
if (argv[0] === "cluster" && argv[1] === "SLOTS") {
return slotTable;
}
});

const setIntervalCalls = sinon.spy(global, "setInterval");
const clearIntervalCalls = sinon.spy(global, "clearInterval");
Expand Down

0 comments on commit d5d85e9

Please sign in to comment.