Skip to content

Commit

Permalink
storage errors test case
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath committed Feb 16, 2021
1 parent 613d932 commit 2f213cb
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/appSession.customStore.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,36 @@ describe('appSession custom store', () => {
assert.isEmpty(loggedOutRes.body);
assert.isEmpty(jar.getCookies(baseUrl));
});

it('should handle storage errors', async () => {
const store = {
get(id, cb) {
process.nextTick(() => cb(null, JSON.parse(sessionData())));
},
async set(id, val, cb) {
process.nextTick(() => cb(new Error('storage error')));
},
async destroy(id, cb) {
process.nextTick(() => cb());
},
};

const conf = getConfig({
...defaultConfig,
sessionStore: store,
});

server = await createServer(appSession(conf));

const jar = request.jar();
const res = await request.get('/session', {
baseUrl,
jar,
json: true,
headers: {
cookie: `appSession=foo`,
},
});
assert.equal(res.statusCode, 500);
});
});

0 comments on commit 2f213cb

Please sign in to comment.