|
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 { |
| 4 | + DualSessionStore, |
| 5 | + DualStoreError, |
| 6 | +} from "../../src/config/dual-session-store.js"; |
4 | 7 | import { type SessionData, Store } from "express-session"; |
5 | 8 |
|
6 | 9 | describe("DualSessionStore", () => { |
@@ -47,14 +50,18 @@ describe("DualSessionStore", () => { |
47 | 50 | }); |
48 | 51 | }); |
49 | 52 |
|
50 | | - it("should return secondary error when both primary and secondary fail", (done) => { |
| 53 | + it("should return combined error when both primary and secondary fail", (done) => { |
| 54 | + const primaryErr = new Error("primary failure"); |
51 | 55 | const secondaryErr = new Error("secondary failure"); |
52 | | - primary.get = sinon.fake((_sid, cb) => cb(new Error("primary failure"))); |
| 56 | + primary.get = sinon.fake((_sid, cb) => cb(primaryErr)); |
53 | 57 | secondary.get = sinon.fake((_sid, cb) => cb(secondaryErr)); |
54 | 58 | store = new DualSessionStore(primary, secondary, "Redis", "DynamoDB"); |
55 | 59 |
|
56 | 60 | store.get(sid, (err) => { |
57 | | - expect(err).to.equal(secondaryErr); |
| 61 | + expect(err).to.be.instanceOf(DualStoreError); |
| 62 | + expect(err.message).to.equal("Both session stores failed"); |
| 63 | + expect(err.primary).to.equal(primaryErr); |
| 64 | + expect(err.secondary).to.equal(secondaryErr); |
58 | 65 | done(); |
59 | 66 | }); |
60 | 67 | }); |
|
0 commit comments