get-connection.test.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var assert = require('assert');
  2. var Pack = require('../../');
  3. describe('Connectable ::', function() {
  4. describe('Get Connection', function() {
  5. var manager;
  6. // Create a manager
  7. before(function(done) {
  8. // Needed to dynamically get the host using the docker container
  9. var host = process.env.MYSQL_PORT_3306_TCP_ADDR || 'localhost';
  10. Pack.createManager({
  11. connectionString: 'mysql://mp:mp@' + host + ':3306/mppg'
  12. })
  13. .exec(function(err, report) {
  14. if (err) {
  15. return done(err);
  16. }
  17. manager = report.manager;
  18. return done();
  19. });
  20. });
  21. it('should successfully return a connection instance', function(done) {
  22. Pack.getConnection({
  23. manager: manager
  24. })
  25. .exec(function(err, report) {
  26. if (err) {
  27. return done(err);
  28. }
  29. // Assert that the report has a client object
  30. assert(report.connection);
  31. // Assert that the connection has a release function
  32. assert(report.connection.release);
  33. return done();
  34. });
  35. });
  36. });
  37. });