Skip to content

Commit

Permalink
test(sessions): fixes session leak tester to not error out on skipped…
Browse files Browse the repository at this point in the history
… tests

Makes sure that sinon doesn't throw errors when tests are skipped
  • Loading branch information
daprahamian committed Feb 23, 2018
1 parent 0487ef3 commit cd1f216
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions test/functional/session_leak_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ function getSessionLeakMetadata(currentTest) {
return (currentTest.metadata && currentTest.metadata.sessions) || {};
}

beforeEach('Session Leak Before Each - Set up clean test environment', () => {
sandbox.restore();
activeSessions = new Set();
pooledSessions = new Set();
activeSessionsBeforeClose = new Set();
});

beforeEach('Session Leak Before Each - setup session tracking', function() {
if (getSessionLeakMetadata(this.currentTest).skipLeakTests) {
return;
}

activeSessions = new Set();
pooledSessions = new Set();
activeSessionsBeforeClose = new Set();

const _acquire = ServerSessionPool.prototype.acquire;
sandbox.stub(ServerSessionPool.prototype, 'acquire').callsFake(function() {
const session = _acquire.apply(this, arguments);
Expand Down Expand Up @@ -87,10 +90,3 @@ afterEach('Session Leak After Each - ensure no leaks', function() {
this.test.error(e);
}
});

afterEach('Session Leak After Each - restore sandbox', () => sandbox.restore());
afterEach('Session Leak After Each - delete sets', () => {
activeSessions = undefined;
activeSessionsBeforeClose = undefined;
pooledSessions = undefined;
});

0 comments on commit cd1f216

Please sign in to comment.