connection-strings.js 837 B

123456789101112131415161718192021222324252627282930
  1. const expect = require('expect.js')
  2. const describe = require('mocha').describe
  3. const it = require('mocha').it
  4. const Pool = require('../')
  5. describe('Connection strings', function () {
  6. it('pool delegates connectionString property to client', function (done) {
  7. const connectionString = 'postgres://foo:bar@baz:1234/xur'
  8. const pool = new Pool({
  9. // use a fake client so we can check we're passed the connectionString
  10. Client: function (args) {
  11. expect(args.connectionString).to.equal(connectionString)
  12. return {
  13. connect: function (cb) {
  14. cb(new Error('testing'))
  15. },
  16. on: function () {},
  17. }
  18. },
  19. connectionString: connectionString,
  20. })
  21. pool.connect(function (err, client) {
  22. expect(err).to.not.be(undefined)
  23. done()
  24. })
  25. })
  26. })