|
1 | 1 | import { afterEach, beforeEach, describe, it } from "mocha"; |
2 | 2 | import { expect, sinon } from "../utils/test-utils.js"; |
3 | | -import { DualSessionStore } from "../../src/config/dual-session-store.js"; |
| 3 | +import { DualSessionStore, DualStoreError } from "../../src/config/dual-session-store.js"; |
4 | 4 | import { SessionData, Store } from "express-session"; |
5 | 5 |
|
6 | 6 | describe("DualSessionStore", () => { |
@@ -45,14 +45,18 @@ describe("DualSessionStore", () => { |
45 | 45 | }); |
46 | 46 | }); |
47 | 47 |
|
48 | | - it("should return secondary error when both primary and secondary fail", (done) => { |
| 48 | + it("should return combined error when both primary and secondary fail", (done) => { |
| 49 | + const primaryErr = new Error("primary failure"); |
49 | 50 | const secondaryErr = new Error("secondary failure"); |
50 | | - primary.get = sinon.fake((_sid, cb) => cb(new Error("primary failure"))); |
| 51 | + primary.get = sinon.fake((_sid, cb) => cb(primaryErr)); |
51 | 52 | secondary.get = sinon.fake((_sid, cb) => cb(secondaryErr)); |
52 | 53 | store = new DualSessionStore(primary, secondary, "Redis", "DynamoDB"); |
53 | 54 |
|
54 | 55 | store.get(sid, (err) => { |
55 | | - expect(err).to.equal(secondaryErr); |
| 56 | + expect(err).to.be.instanceOf(DualStoreError); |
| 57 | + expect(err.message).to.equal("Both session stores failed"); |
| 58 | + expect(err.primary).to.equal(primaryErr); |
| 59 | + expect(err.secondary).to.equal(secondaryErr); |
56 | 60 | done(); |
57 | 61 | }); |
58 | 62 | }); |
|
0 commit comments