Skip to content

Commit

Permalink
Labrc Tests 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrumwell committed Nov 10, 2017
1 parent 2166e0f commit 1a2de60
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .labrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
globals: '__BluebirdErrorTypes__,Set,Intl,Map,__core-js_shared__,System,Observable,regeneratorRuntime,asap,core,_babelPolyfill,WebAssembly',
verbose: true,
}
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ESLINT = node_modules/.bin/eslint
LAB = ./node_modules/lab/bin/lab
BABEL = ./node_modules/.bin/babel
KNEX_VERSIONS = 0.8 0.9 0.10 0.11 0.12 0.13
KNEX_VERSIONS = 0.8 0.9 0.10 0.11 0.12 0.13 0.14

.PHONY: clean test lint lint-quiet watch build test-debug $(KNEX_VERSIONS)

Expand All @@ -11,7 +11,7 @@ clean:
-rm -rf ./dist

test:
${LAB} -v -I __BluebirdErrorTypes__,Set,Intl,Map,__core-js_shared__,System,Observable,regeneratorRuntime,asap,core,_babelPolyfill ./test/init.js
${LAB} ./test/init.js

test-suite: $(KNEX_VERSIONS)

Expand All @@ -20,7 +20,7 @@ $(KNEX_VERSIONS):
make test

debug:
BLUEBIRD_DEBUG=1 DEBUG=pool2 node-debug -p 8888 ${LAB} -m 0 -v -I __BluebirdErrorTypes__,Set,Intl,Map,__core-js_shared__,System,Observable,regeneratorRuntime,asap,core,_babelPolyfill ./test/init.js
BLUEBIRD_DEBUG=1 DEBUG=pool2 node-debug -p 8888 ${LAB} -m 0 ./test/init.js

lint:
$(ESLINT) --ext .js --ext .jsx .
Expand Down
13 changes: 13 additions & 0 deletions dist/platforms/knex/0.14/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _index = require('../0.12/index');

var _index2 = _interopRequireDefault(_index);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = _index2.default;
4 changes: 2 additions & 2 deletions dist/platforms/knex/0.8/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ var spec = exports.spec = {
define: defineConnection(connection)
};

function makeClient(spec) {
function makeClient(def) {
return {
mock: function mock(db) {
return _transformer2.default.transform(db, spec);
return _transformer2.default.transform(db, def);
},
unmock: function unmock(db) {
return _transformer2.default.restore(db);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"sqlite3": "^3.0.8"
},
"peerDependencies": {
"knex": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0"
"knex": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^0.14.0"
},
"dependencies": {
"bluebird": "^3.4.1",
Expand Down
3 changes: 3 additions & 0 deletions src/platforms/knex/0.14/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import client from '../0.12/index';

export default client;
4 changes: 2 additions & 2 deletions src/platforms/knex/0.8/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ export let spec = {
define : defineConnection(connection),
};

export function makeClient(spec) {
export function makeClient(def) {
return {
mock(db) {
return transformer.transform(db, spec);
return transformer.transform(db, def);
},

unmock(db) {
Expand Down
10 changes: 5 additions & 5 deletions test/common/bookshelf.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ export default (db) => {

it('should work with Model#count', (done) => {
tracker.on('query', (query) => {
try {
expect(query.sql).to.equal('select count("count") as "count" from "models" where "color" = ?');
} catch (e) {
expect(query.sql).to.equal('select count(`count`) as `count` from `models` where `color` = ?');
}
expect([
'select count("count") as "count" from "models" where "color" = $1',
'select count("count") as "count" from "models" where "color" = ?',
'select count(`count`) as `count` from `models` where `color` = ?',
]).to.contain(query.sql);

expect(query.method).to.equal('select');

Expand Down
6 changes: 5 additions & 1 deletion test/mysql/knex.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ export default (db) => {
it('should support schema#hasTable', (done) => {
tracker.on('query', (query) => {
expect(query.sql).to.be.a('string');
expect(query.sql).to.equal('show tables like ?');

expect([
'show tables like ?',
'select * from information_schema.tables where table_name = ? and table_schema = database()',
]).to.contain(query.sql);

done();
});
Expand Down
11 changes: 6 additions & 5 deletions test/postgres/knex.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ export default (db) => {
it('should support schema#hasTable', (done) => {
tracker.on('query', (query) => {
expect(query.sql).to.be.a('string');
try {
expect(query.sql).to.equal('select * from information_schema.tables where table_name = ? and table_schema = current_schema');
} catch (e) {
expect(query.sql).to.equal('select * from information_schema.tables where table_name = ?');
}

expect([
'select * from information_schema.tables where table_name = ? and table_schema = current_schema',
'select * from information_schema.tables where table_name = ?',
'select * from information_schema.tables where table_name = $1 and table_schema = current_schema',
]).to.contain(query.sql);

done();
});
Expand Down

0 comments on commit 1a2de60

Please sign in to comment.