Skip to content

Commit

Permalink
run shared tests from both v3 and v4 of juggler
Browse files Browse the repository at this point in the history
  • Loading branch information
nabdelgadir committed Jul 16, 2019
1 parent 2ae380a commit 5f6afca
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 5 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/node_modules/
8 changes: 8 additions & 0 deletions deps/juggler-v3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "juggler-v3",
"version": "3.0.0",
"dependencies": {
"loopback-datasource-juggler": "3.x",
"should": "^13.2.3"
}
}
24 changes: 24 additions & 0 deletions deps/juggler-v3/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: loopback-connector-oracle
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

'use strict';

const juggler = require('loopback-datasource-juggler');
const name = require('./package.json').name;

require('../../test/init/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/include.test.js');
});
8 changes: 8 additions & 0 deletions deps/juggler-v4/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "juggler-v4",
"version": "4.0.0",
"dependencies": {
"loopback-datasource-juggler": "4.x",
"should": "^13.2.3"
}
}
24 changes: 24 additions & 0 deletions deps/juggler-v4/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: loopback-connector-oracle
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

'use strict';

const juggler = require('loopback-datasource-juggler');
const name = require('./package.json').name;

require('../../test/init/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/include.test.js');
});
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"main": "index.js",
"scripts": {
"lint": "eslint .",
"test": "mocha --UV_THREADPOOL_SIZE=100 --require test/init/init.js test/*.js",
"test": "mocha test/*.test.js node_modules/juggler-v3/test.js node_modules/juggler-v4/test.js",
"posttest": "npm run lint"
},
"dependencies": {
Expand All @@ -29,7 +29,9 @@
"bluebird": "^3.3.3",
"eslint": "^3.17.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": "^5.2.0",
"rc": "^1.0.0",
"should": "^8.0.2"
Expand Down
10 changes: 9 additions & 1 deletion test/init/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

'use strict';

var DataSource = require('loopback-datasource-juggler').DataSource;
const juggler = require('loopback-datasource-juggler');
let DataSource = juggler.DataSource;

var config = require('rc')('loopback', {test: {oracle: {}}}).test.oracle;
config.maxConn = 64;
Expand All @@ -23,6 +24,13 @@ global.getDataSource = global.getSchema = function() {
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,
Expand Down
4 changes: 2 additions & 2 deletions test/oracle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
/* global getDataSource */
var juggler = require('loopback-datasource-juggler');
var CreateDS = juggler.DataSource;
require('loopback-datasource-juggler/test/common.batch.js');
require('loopback-datasource-juggler/test/include.test.js');
// require('loopback-datasource-juggler/test/common.batch.js');
// require('loopback-datasource-juggler/test/include.test.js');

require('./init/init');
var should = require('should');
Expand Down

0 comments on commit 5f6afca

Please sign in to comment.