Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run shared tests from both v3 and v4 of juggler #43

Merged
merged 1 commit into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage/
**/node_modules/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
*.tgz
node_modules
checkstyle.xml
**/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": "^8.4.0"
}
}
33 changes: 33 additions & 0 deletions deps/juggler-v3/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 createDataSource = require('../../test/helpers/data-source-factory');
const kvaoTestSuite = require('loopback-datasource-juggler/test/kvao.suite.js');
const juggler = require('loopback-datasource-juggler');
const name = require('./package.json').name;

describe(name, function() {
before(function() {
return createDataSource.resetDataSourceClass(juggler.DataSource);
});

after(function() {
return createDataSource.resetDataSourceClass();
});

context('using binary packer', function() {
kvaoTestSuite(createDataSource);
});

context('using json-string packer', function() {
kvaoTestSuite(createDataSource.json);
});

context('using json-string packer with hex buffers', function() {
kvaoTestSuite(createDataSource.jsonWithHexBuffers);
});
});
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": "3.0.0",
"dependencies": {
"loopback-datasource-juggler":"4.x",
"should": "^13.2.3"
}
}
33 changes: 33 additions & 0 deletions deps/juggler-v4/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 createDataSource = require('../../test/helpers/data-source-factory');
const kvaoTestSuite = require('loopback-datasource-juggler/test/kvao.suite.js');
const juggler = require('loopback-datasource-juggler');
const name = require('./package.json').name;

describe(name, function() {
before(function() {
return createDataSource.resetDataSourceClass(juggler.DataSource);
});

after(function() {
return createDataSource.resetDataSourceClass();
});

context('using binary packer', function() {
kvaoTestSuite(createDataSource);
});

context('using json-string packer', function() {
kvaoTestSuite(createDataSource.json);
});

context('using json-string packer with hex buffers', function() {
kvaoTestSuite(createDataSource.jsonWithHexBuffers);
});
});
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"main": "lib/kv-redis.js",
"scripts": {
"test": "mocha test/integration",
"test": "mocha test/integration node_modules/juggler-v3/test.js node_modules/juggler-v4/test.js",
"posttest": "npm run lint",
"lint": "eslint ."
},
Expand All @@ -36,6 +36,8 @@
"dirty-chai": "^2.0.1",
"eslint": "^4.19.1",
"eslint-config-loopback": "^10.0.0",
"juggler-v3": "file:./deps/juggler-v3",
"juggler-v4": "file:./deps/juggler-v4",
"loopback-datasource-juggler": "^3.0.0",
"mocha": "^5.2.0",
"should": "^8.4.0"
Expand Down
7 changes: 6 additions & 1 deletion test/helpers/data-source-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

'use strict';

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

const SETTINGS = {
host: process.env.REDIS_HOST || 'localhost',
Expand Down Expand Up @@ -62,6 +63,10 @@ createDataSource.jsonWithHexBuffers = function(options) {
return createDataSource(settings);
};

createDataSource.resetDataSourceClass = function(ctor) {
DataSource = ctor || juggler.DataSource;
};

beforeEach(function clearDatabase(done) {
const ds = createDataSource();
ds.connector.execute('FLUSHDB', function(err) {
Expand Down
24 changes: 0 additions & 24 deletions test/integration/juggler-api.integration.js

This file was deleted.