test-connection-limit.js 636 B

123456789101112131415161718192021222324252627
  1. var common = require('../../common');
  2. var assert = require('assert');
  3. var pool = common.createPool({
  4. connectionLimit : 1,
  5. waitForConnections : false
  6. });
  7. pool.getConnection(function(err, connection) {
  8. if (err) throw err;
  9. pool.getConnection(function(err) {
  10. assert.ok(err);
  11. var shouldGetConnection = false;
  12. pool.config.waitForConnections = true;
  13. pool.getConnection(function(err, connection2) {
  14. if (err) throw err;
  15. assert.ok(shouldGetConnection);
  16. assert.strictEqual(connection, connection2);
  17. pool.end();
  18. });
  19. shouldGetConnection = true;
  20. connection.end();
  21. });
  22. });