feat: run shared tests
This commit is contained in:
parent
869061c6f2
commit
2316300b9a
|
@ -0,0 +1 @@
|
|||
**/node_modules/
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "juggler-v3",
|
||||
"version": "3.0.0",
|
||||
"dependencies": {
|
||||
"loopback-datasource-juggler":"3.x",
|
||||
"should": "^8.4.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright IBM Corp. 2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-postgresql
|
||||
// This file is licensed under the Artistic License 2.0.
|
||||
// License text available at https://opensource.org/licenses/Artistic-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const semver = require('semver');
|
||||
const should = require('should');
|
||||
const juggler = require('loopback-datasource-juggler');
|
||||
const name = require('./package.json').name;
|
||||
|
||||
require('../../test/init');
|
||||
|
||||
describe(name, function() {
|
||||
before(function() {
|
||||
return global.resetDataSourceClass(juggler.DataSource);
|
||||
});
|
||||
|
||||
after(function() {
|
||||
return global.resetDataSourceClass();
|
||||
});
|
||||
|
||||
require('loopback-datasource-juggler/test/common.batch.js');
|
||||
require('loopback-datasource-juggler/test/default-scope.test.js');
|
||||
require('loopback-datasource-juggler/test/include.test.js');
|
||||
|
||||
// === Operation hooks ==== //
|
||||
|
||||
const suite = require('loopback-datasource-juggler/test/persistence-hooks.suite.js');
|
||||
|
||||
const DB_VERSION = process.env.MONGODB_VERSION;
|
||||
|
||||
if (!DB_VERSION) {
|
||||
console.log('The ENV variable MONGODB_VERSION is not set.' +
|
||||
' Assuming MongoDB version 2.6 or newer.');
|
||||
}
|
||||
|
||||
const DB_HAS_2_6_FEATURES = (!DB_VERSION ||
|
||||
semver.satisfies(DB_VERSION, '>=2.6.0'));
|
||||
|
||||
const customConfig = Object.assign({}, global.config, {
|
||||
enableOptimisedFindOrCreate: DB_HAS_2_6_FEATURES,
|
||||
});
|
||||
|
||||
suite(global.getDataSource(customConfig, juggler.DataSource), should, {
|
||||
replaceOrCreateReportsNewInstance: DB_HAS_2_6_FEATURES,
|
||||
});
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "juggler-v4",
|
||||
"version": "4.0.0",
|
||||
"dependencies": {
|
||||
"loopback-datasource-juggler":"4.x",
|
||||
"should": "^13.2.3"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright IBM Corp. 2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-postgresql
|
||||
// This file is licensed under the Artistic License 2.0.
|
||||
// License text available at https://opensource.org/licenses/Artistic-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const semver = require('semver');
|
||||
const should = require('should');
|
||||
const juggler = require('loopback-datasource-juggler');
|
||||
const name = require('./package.json').name;
|
||||
|
||||
require('../../test/init');
|
||||
|
||||
describe(name, function() {
|
||||
before(function() {
|
||||
return global.resetDataSourceClass(juggler.DataSource);
|
||||
});
|
||||
|
||||
after(function() {
|
||||
return global.resetDataSourceClass();
|
||||
});
|
||||
|
||||
require('loopback-datasource-juggler/test/common.batch.js');
|
||||
require('loopback-datasource-juggler/test/default-scope.test.js');
|
||||
require('loopback-datasource-juggler/test/include.test.js');
|
||||
|
||||
// === Operation hooks ==== //
|
||||
|
||||
const suite = require('loopback-datasource-juggler/test/persistence-hooks.suite.js');
|
||||
|
||||
const DB_VERSION = process.env.MONGODB_VERSION;
|
||||
|
||||
if (!DB_VERSION) {
|
||||
console.log('The ENV variable MONGODB_VERSION is not set.' +
|
||||
' Assuming MongoDB version 2.6 or newer.');
|
||||
}
|
||||
|
||||
const DB_HAS_2_6_FEATURES = (!DB_VERSION ||
|
||||
semver.satisfies(DB_VERSION, '>=2.6.0'));
|
||||
|
||||
const customConfig = Object.assign({}, global.config, {
|
||||
enableOptimisedFindOrCreate: DB_HAS_2_6_FEATURES,
|
||||
});
|
||||
|
||||
suite(global.getDataSource(customConfig, juggler.DataSource), should, {
|
||||
replaceOrCreateReportsNewInstance: DB_HAS_2_6_FEATURES,
|
||||
});
|
||||
});
|
File diff suppressed because it is too large
Load Diff
|
@ -9,7 +9,7 @@
|
|||
"scripts": {
|
||||
"pretest": "node pretest.js",
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --timeout 10000 --require test/init.js test/*.js",
|
||||
"test": "mocha --timeout 10000 test/*.test.js node_modules/juggler-v3/test.js node_modules/juggler-v4/test.js",
|
||||
"posttest": "npm run lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -24,7 +24,9 @@
|
|||
"bluebird": "~2.9.10",
|
||||
"eslint": "^4.3.0",
|
||||
"eslint-config-loopback": "^8.0.0",
|
||||
"loopback-datasource-juggler": "^3.0.0",
|
||||
"juggler-v3": "file:./deps/juggler-v3",
|
||||
"juggler-v4": "file:./deps/juggler-v4",
|
||||
"loopback-datasource-juggler": "^3.0.0 || ^4.0.0",
|
||||
"mocha": "^2.1.0",
|
||||
"rc": "^1.0.0",
|
||||
"should": "^8.0.2",
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright IBM Corp. 2013,2016. All Rights Reserved.
|
||||
// Node module: loopback-connector-mysql
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
'use strict';
|
||||
describe('mysql imported features', function() {
|
||||
before(function() {
|
||||
require('./init.js');
|
||||
});
|
||||
|
||||
require('loopback-datasource-juggler/test/common.batch.js');
|
||||
require('loopback-datasource-juggler/test/include.test.js');
|
||||
});
|
13
test/init.js
13
test/init.js
|
@ -28,11 +28,20 @@ global.getConfig = function(options) {
|
|||
return dbConf;
|
||||
};
|
||||
|
||||
global.getDataSource = global.getSchema = function(options) {
|
||||
var db = new DataSource(require('../'), global.getConfig(options));
|
||||
global.getDataSource = global.getSchema = function(options, customClass) {
|
||||
const ctor = customClass || DataSource;
|
||||
const db = new ctor(require('../'), global.getConfig(options));
|
||||
// var db = new DataSource(require('../'), global.getConfig(options));
|
||||
return db;
|
||||
};
|
||||
|
||||
global.resetDataSourceClass = function(ctor) {
|
||||
DataSource = ctor || juggler.DataSource;
|
||||
const promise = db ? db.disconnect() : Promise.resolve();
|
||||
db = undefined;
|
||||
return promise;
|
||||
};
|
||||
|
||||
global.connectorCapabilities = {
|
||||
ilike: false,
|
||||
nilike: false,
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
// Copyright IBM Corp. 2015,2017. All Rights Reserved.
|
||||
// Node module: loopback-connector-mysql
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
'use strict';
|
||||
var should = require('./init');
|
||||
var suite = require('loopback-datasource-juggler/test/persistence-hooks.suite.js');
|
||||
|
||||
suite(global.getDataSource(), should, {
|
||||
replaceOrCreateReportsNewInstance: false,
|
||||
});
|
Loading…
Reference in New Issue