Skip to content

Commit

Permalink
test: added integration test for end event of the stream
Browse files Browse the repository at this point in the history
  • Loading branch information
tommarien committed Nov 8, 2022
1 parent ac78e29 commit f336d5f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/integration/test-pool-end.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const { createPool } = require('../common.js');
const assert = require('assert');

const pool = createPool();

pool.getConnection((err, conn) => {
assert.ifError(err);

assert(pool._allConnections.length === 1);
assert(pool._freeConnections.length === 0);

// emit the end event, so the connection gets removed from the pool
conn.stream.emit('end');

assert(pool._allConnections.length === 0);
assert(pool._freeConnections.length === 0);

// As the connection has not really ended we need to this ourselves
conn.destroy();
});

0 comments on commit f336d5f

Please sign in to comment.