Skip to content

Commit

Permalink
Update test to assert on current behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
W-A-James committed May 10, 2024
1 parent 72c22b9 commit 68f1eec
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@ describe('CSOT spec unit tests', function () {
client = this.configuration.newClient({ timeoutMS: 1000 });
// Spy on connection checkout and pull options argument
const checkoutSpy = sinon.spy(ConnectionPool.prototype, 'checkOut');
const remainingTimeSpy = sinon.spy(Timeout.prototype, 'remainingTime', ['get']);
const selectServerSpy = sinon.spy(Topology.prototype, 'selectServer');
const expiresSpy = sinon.spy(Timeout, 'expires');

await client.db('db').collection('collection').insertOne({ x: 1 });
const remainingTimeFirstCall = remainingTimeSpy.get.firstCall;

expect(checkoutSpy).to.have.been.calledOnce;
expect(checkoutSpy.firstCall.args[0].timeout).to.exist;
expect(checkoutSpy.firstCall.args[0].timeout.duration).to.be.approximately(
remainingTimeFirstCall.returnValue,
3
// Check that we passed through the timeout
expect(checkoutSpy.firstCall.args[0].timeout).to.equal(
selectServerSpy.lastCall.lastArg.timeout
);

// Check that no more Timeouts are constructed after we enter checkout
expect(!expiresSpy.calledAfter(checkoutSpy));
});

it('If timeoutMS is not set for an operation, waitQueueTimeoutMS should apply to connection checkout after a server has been selected.', async function () {
Expand Down

0 comments on commit 68f1eec

Please sign in to comment.