Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: cover the reconnectOnError select failure with one unit case
Replace the mock-server test with a single case in test/unit/redis.ts that
calls handleReconnection directly, as suggested in review.
  • Loading branch information
askalf committed Oct 13, 2026
commit bb87c3c75c006188f956537aeab0f342f4770b40
83 changes: 0 additions & 83 deletions test/unit/reconnectOnError.ts

This file was deleted.

18 changes: 18 additions & 0 deletions test/unit/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,22 @@ describe("Redis", () => {
command.verify();
});
});

describe("#handleReconnection", () => {
it("emits an error when the db-restoring select fails on reconnectOnError", async () => {
const redis = new Redis({ lazyConnect: true, reconnectOnError: () => 2 });
const selectError = new Error("ERR DB index is out of range");
sinon.stub(redis, "disconnect");
sinon.stub(redis, "sendCommand");
sinon.stub(redis, "select").rejects(selectError);
const emitted = new Promise((resolve) => redis.once("error", resolve));

redis.handleReconnection(new Error("READONLY"), {
command: new Command("get", ["foo"]),
select: 2,
});

expect(await emitted).to.equal(selectError);
});
});
});
Loading