2014-09-01 17:18:45 +02:00
|
|
|
'use strict';
|
|
|
|
|
2020-03-08 19:48:23 -04:00
|
|
|
const { expect } = require('chai');
|
|
|
|
|
2020-04-19 00:40:23 +02:00
|
|
|
module.exports = function (knex) {
|
2018-10-15 22:29:53 -04:00
|
|
|
const sinon = require('sinon');
|
2013-12-27 14:44:21 -05:00
|
|
|
|
2020-04-19 00:40:23 +02:00
|
|
|
describe(knex.client.dialect + ' | ' + knex.client.driverName, function () {
|
2018-08-29 17:13:16 +02:00
|
|
|
this.client = knex.client.dialect;
|
2015-04-24 10:10:34 -04:00
|
|
|
this.driverName = knex.client.driverName;
|
2013-12-27 14:44:21 -05:00
|
|
|
|
2020-04-19 00:40:23 +02: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);
|
2020-05-05 19:10:50 +02:00
|
|
|
require('./migrate/migration-integration-tests')(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);
|
2020-09-30 09:05:16 +02:00
|
|
|
require('./datatype/decimal')(knex);
|
|
|
|
require('./datatype/double')(knex);
|
2014-06-12 13:56:10 -04:00
|
|
|
|
2020-04-19 00:40:23 +02:00
|
|
|
describe('knex.destroy', function () {
|
|
|
|
it('should allow destroying the pool with knex.destroy', function () {
|
2018-10-15 22:29:53 -04:00
|
|
|
const spy = sinon.spy(knex.client.pool, 'destroy');
|
2018-07-09 08:10:34 -04:00
|
|
|
return knex
|
|
|
|
.destroy()
|
2020-04-19 00:40:23 +02:00
|
|
|
.then(function () {
|
2018-07-09 08:10:34 -04:00
|
|
|
expect(spy).to.have.callCount(1);
|
|
|
|
expect(knex.client.pool).to.equal(undefined);
|
|
|
|
return knex.destroy();
|
|
|
|
})
|
2020-04-19 00:40:23 +02:00
|
|
|
.then(function () {
|
2018-07-09 08:10:34 -04:00
|
|
|
expect(spy).to.have.callCount(1);
|
|
|
|
});
|
2014-06-12 13:56:10 -04:00
|
|
|
});
|
|
|
|
});
|
2013-12-27 14:44:21 -05:00
|
|
|
});
|
|
|
|
|
2020-04-19 00:40:23 +02:00
|
|
|
describe('knex.initialize', function () {
|
|
|
|
it('should allow initialize the pool with knex.initialize', function () {
|
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);
|
2018-10-15 22:29:53 -04:00
|
|
|
const waitForDestroy = knex.destroy();
|
2018-07-02 22:52:32 +02:00
|
|
|
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
|
|
|
};
|