2014-09-01 17:18:45 +02:00
|
|
|
/*global expect, describe, it*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2013-12-27 14:44:21 -05:00
|
|
|
module.exports = function(knex) {
|
2014-06-12 13:56:10 -04:00
|
|
|
var sinon = require('sinon');
|
2013-12-27 14:44:21 -05:00
|
|
|
|
2015-04-22 10:34:14 -04:00
|
|
|
describe(knex.client.dialect + ' | ' + knex.client.driverName, function() {
|
2018-07-09 08:10:34 -04:00
|
|
|
this.dialect = knex.client.dialect;
|
2015-04-24 10:10:34 -04:00
|
|
|
this.driverName = knex.client.driverName;
|
2013-12-27 14:44:21 -05:00
|
|
|
|
2016-09-13 18:12:23 -04:00
|
|
|
after(function() {
|
2018-07-09 08:10:34 -04:00
|
|
|
return knex.destroy();
|
2018-04-05 01:19:08 +03:00
|
|
|
});
|
2016-09-13 18:12:23 -04:00
|
|
|
|
2013-12-27 14:44:21 -05:00
|
|
|
require('./schema')(knex);
|
2014-04-27 12:00:51 +03:00
|
|
|
require('./migrate')(knex);
|
2018-04-05 01:19:08 +03:00
|
|
|
|
2014-07-21 18:38:40 -04:00
|
|
|
require('./seed')(knex);
|
2013-12-27 14:44:21 -05:00
|
|
|
require('./builder/inserts')(knex);
|
|
|
|
require('./builder/selects')(knex);
|
|
|
|
require('./builder/unions')(knex);
|
|
|
|
require('./builder/joins')(knex);
|
|
|
|
require('./builder/aggregate')(knex);
|
|
|
|
require('./builder/updates')(knex);
|
|
|
|
require('./builder/transaction')(knex);
|
|
|
|
require('./builder/deletes')(knex);
|
|
|
|
require('./builder/additional')(knex);
|
2016-05-29 18:16:32 +02:00
|
|
|
require('./datatype/bigint')(knex);
|
2014-06-12 13:56:10 -04:00
|
|
|
|
|
|
|
describe('knex.destroy', function() {
|
|
|
|
it('should allow destroying the pool with knex.destroy', function() {
|
2018-02-07 11:17:17 +02:00
|
|
|
var spy = sinon.spy(knex.client.pool, 'destroy');
|
2018-07-09 08:10:34 -04:00
|
|
|
return knex
|
|
|
|
.destroy()
|
|
|
|
.then(function() {
|
|
|
|
expect(spy).to.have.callCount(1);
|
|
|
|
expect(knex.client.pool).to.equal(undefined);
|
|
|
|
return knex.destroy();
|
|
|
|
})
|
|
|
|
.then(function() {
|
|
|
|
expect(spy).to.have.callCount(1);
|
|
|
|
});
|
2014-06-12 13:56:10 -04:00
|
|
|
});
|
|
|
|
});
|
2013-12-27 14:44:21 -05:00
|
|
|
});
|
|
|
|
|
2018-07-02 22:52:32 +02:00
|
|
|
describe('knex.initialize', function() {
|
|
|
|
it('should allow initialize the pool with knex.initialize', function() {
|
2018-07-08 14:10:51 +03:00
|
|
|
// TODO: fix to work with oracle too
|
|
|
|
if (knex.client.driverName === 'oracledb') {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-02 22:52:32 +02:00
|
|
|
expect(knex.client.pool).to.equal(undefined);
|
|
|
|
knex.initialize();
|
|
|
|
expect(knex.client.pool.destroyed).to.equal(false);
|
|
|
|
let waitForDestroy = knex.destroy();
|
|
|
|
expect(knex.client.pool.destroyed).to.equal(true);
|
|
|
|
return waitForDestroy.then(() => {
|
|
|
|
expect(knex.client.pool).to.equal(undefined);
|
|
|
|
knex.initialize();
|
2018-07-09 08:10:34 -04:00
|
|
|
expect(knex.client.pool.destroyed).to.equal(false);
|
|
|
|
});
|
2018-07-02 22:52:32 +02:00
|
|
|
});
|
|
|
|
});
|
2014-09-01 17:18:45 +02:00
|
|
|
};
|