Skip to content

Commit

Permalink
Added driver prefix to all tests. Normalized whitespace characters in…
Browse files Browse the repository at this point in the history
… tests.
  • Loading branch information
Kyle Farris authored and kylefarris committed Feb 1, 2019
1 parent f48556e commit f908251
Show file tree
Hide file tree
Showing 55 changed files with 1,378 additions and 1,388 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#TESTS = test/mysql/*.js test/mssql/*.js
TESTS = test/mysql/*.js test/mssql/*.js
#TESTS = test/mssql/*.js
#TESTS = test/mssql/04-tests-query-response.js
TESTS = test/mssql/05-tests-multiple-queries.js
#TESTS = test/mssql/05-tests-multiple-queries.js
#TESTS = test/mssql/03-tests-insert.js
test:
mocha --timeout 5000 --reporter spec $(TESTS)
Expand Down
4 changes: 0 additions & 4 deletions drivers/mssql/query_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ class QueryExec extends QueryBuilder {

_exec(sql, cb) {
if (Object.prototype.toString.call(this._connection) === Object.prototype.toString.call({})) {
console.log("The Query: ", sql);
const request = new Request(sql, (err, count, results) => {
// console.log("Results:" , results);
// console.log("Count:" , count);

// Standardize some important properties
if (!err && results && Array.isArray(results)) {
if (results.length === 0) {
Expand Down
Empty file added test/05-multiple-drivers.js
Empty file.
2 changes: 1 addition & 1 deletion test/mssql/00-AA-tests-general.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const should = require('chai').should();

describe('QueryBuilder', () => {
describe('MSSQL: QueryBuilder', () => {
it('actually exists and can be initialized', () => {
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/00-tests-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const connection_released = qb => {
}, 100);
};

describe('QueryBuilder() - MS SQL Adapter', () => {
describe('MSSQL: QueryBuilder() - Adapter', () => {
const driver = 'mssql';
const settings = {
host: 'localhost',
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/01-tests-distinct.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('distinct()', () => {
describe('MSSQL: distinct()', () => {
it('should exist', () => {
should.exist(qb.distinct);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/01-tests-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const should = require('chai').should();
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('from()', () => {
describe('MSSQL: from()', () => {
it('should exist', () => {
should.exist(qb.from);
});
Expand Down
6 changes: 3 additions & 3 deletions test/mssql/01-tests-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('get()', () => {
describe('MSSQL: get()', () => {
it('should exist', () => {
should.exist(qb.get);
});
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('get()', () => {
it('should accept a limit on the number of rows selected', () => {
qb.reset_query();
const sql = qb.limit(20).get('galaxies');
sql.should.eql("SELECT TOP 20 * FROM [galaxies]");
sql.should.eql("SELECT TOP (20) * FROM [galaxies]");
});
it('should accept a LIMIT on the number of rows to select and an OFFSET at which to start selecting the rows', () => {
qb.reset_query();
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('get()', () => {
});
});

describe('get_where()', () => {
describe('MSSQL: get_where()', () => {
it('should exist', () => {
should.exist(qb.get_where);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/01-tests-groupby.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('group_by()', () => {
describe('MSSQL: group_by()', () => {
it('should exist', () => {
should.exist(qb.group_by);
});
Expand Down
4 changes: 2 additions & 2 deletions test/mssql/01-tests-having.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('having()', () => {
describe('MSSQL: having()', () => {
it('should exist', () => {
should.exist(qb.having);
});
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('having()', () => {
});
});

describe('or_having()', () => {
describe('MSSQL: or_having()', () => {
it('should exist', () => {
should.exist(qb.or_having);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/01-tests-join.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('join()', () => {
describe('MSSQL: join()', () => {
it('should exist', () => {
should.exist(qb.join);
});
Expand Down
8 changes: 4 additions & 4 deletions test/mssql/01-tests-like.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('like()', () => {
describe('MSSQL: like()', () => {
it('should exist', () => {
should.exist(qb.like);
});
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('like()', () => {
});
});

describe('or_like()', () => {
describe('MSSQL: or_like()', () => {
it('should exist', () => {
should.exist(qb.or_like);
});
Expand All @@ -128,7 +128,7 @@ describe('or_like()', () => {
});
});

describe('not_like()', () => {
describe('MSSQL: not_like()', () => {
it('should exist', () => {
should.exist(qb.not_like);
});
Expand Down Expand Up @@ -158,7 +158,7 @@ describe('not_like()', () => {
});
});

describe('or_not_like()', () => {
describe('MSSQL: or_not_like()', () => {
it('should exist', () => {
should.exist(qb.or_not_like);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/01-tests-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('limit()', () => {
describe('MSSQL: limit()', () => {
it('should exist', () => {
should.exist(qb.limit);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/01-tests-offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('offset()', () => {
describe('MSSQL: offset()', () => {
it('should exist', () => {
should.exist(qb.offset);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/01-tests-orderby.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('order_by()', () => {
describe('MSSQL: order_by()', () => {
it('should exist', () => {
should.exist(qb.order_by);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/01-tests-returning.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('returning()', () => {
describe('MSSQL: returning()', () => {
it('should exist', () => {
should.exist(qb.returning);
});
Expand Down
4 changes: 2 additions & 2 deletions test/mssql/01-tests-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('select()', () => {
describe('MSSQL: select()', () => {
it('should exist', () => {
should.exist(qb.select);
});
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('select()', () => {
const prefixes = ['min','max','avg','sum'];
for (const i in prefixes) {
const type = prefixes[i];
describe('select_' + type+'()', () => {
describe('MSSQL: select_' + type+'()', () => {
it('should exist', () => {
should.exist(qb['select_' + type]);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/01-tests-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('set()', () => {
describe('MSSQL: set()', () => {
it('should exist', () => {
should.exist(qb.set);
});
Expand Down
4 changes: 2 additions & 2 deletions test/mssql/01-tests-where.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('where()', () => {
describe('MSSQL: where()', () => {
it('should exist', () => {
should.exist(qb.where);
});
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('where()', () => {
});
});

describe('or_where()', () => {
describe('MSSQL: or_where()', () => {
it('should exist', () => {
should.exist(qb.or_where);
});
Expand Down
8 changes: 4 additions & 4 deletions test/mssql/01-tests-where_in.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('where_in()', () => {
describe('MSSQL: where_in()', () => {
it('should exist', () => {
should.exist(qb.where_in);
});
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('where_in()', () => {
});
});

describe('where_not_in()', () => {
describe('MSSQL: where_not_in()', () => {
it('should exist', () => {
should.exist(qb.where_not_in);
});
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('where_not_in()', () => {
});
});

describe('or_where_in()', () => {
describe('MSSQL: or_where_in()', () => {
it('should exist', () => {
should.exist(qb.or_where_in);
});
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('or_where_in()', () => {
});
});

describe('or_where_not_in()', () => {
describe('MSSQL: or_where_not_in()', () => {
it('should exist', () => {
should.exist(qb.or_where_in);
});
Expand Down
8 changes: 4 additions & 4 deletions test/mssql/02-tests-compilation_methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('get_compiled_select()', () => {
describe('MSSQL: get_compiled_select()', () => {
it('should exist', () => {
should.exist(qb.get_compiled_select);
});
Expand All @@ -27,7 +27,7 @@ describe('get_compiled_select()', () => {
});
});

describe('get_compiled_insert()', () => {
describe('MSSQL: get_compiled_insert()', () => {
it('should exist', () => {
should.exist(qb.get_compiled_insert);
});
Expand All @@ -41,7 +41,7 @@ describe('get_compiled_insert()', () => {
});
});

describe('get_compiled_update()', () => {
describe('MSSQL: get_compiled_update()', () => {
it('should exist', () => {
should.exist(qb.get_compiled_update);
});
Expand All @@ -55,7 +55,7 @@ describe('get_compiled_update()', () => {
});
});

describe('get_compiled_delete()', () => {
describe('MSSQL: get_compiled_delete()', () => {
it('should exist', () => {
should.exist(qb.get_compiled_delete);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/03-tests-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('count()', () => {
describe('MSSQL: count()', () => {
it('should exist', () => {
should.exist(qb.count);
});
Expand Down
4 changes: 2 additions & 2 deletions test/mssql/03-tests-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('delete()', () => {
describe('MSSQL: delete()', () => {
it('should exist', () => {
should.exist(qb.delete);
});
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('delete()', () => {
it('should accept a limit on the number of rows deleted', () => {
qb.reset_query();
const sql = qb.limit(20).delete('galaxies');
sql.should.eql("DELETE TOP 20 FROM [galaxies]");
sql.should.eql("DELETE TOP (20) FROM [galaxies]");
});
it('should not a allow an offset delete', () => {
qb.reset_query();
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/03-tests-empty_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('emtpy_table()', () => {
describe('MSSQL: emtpy_table()', () => {
it('should exist', () => {
should.exist(qb.empty_table);
});
Expand Down
4 changes: 2 additions & 2 deletions test/mssql/03-tests-insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const test_data_set = [{id:3, name:'Milky Way', type: 'spiral'}, {id:4, name: 'A

// table, data, callback, ignore, suffix

describe('insert()', () => {
describe('MSSQL: insert()', () => {
it('should exist', () => {
should.exist(qb.insert);
});
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('insert()', () => {
});
});

describe('insert_ignore()', () => {
describe('MSSQL: insert_ignore()', () => {
it('should exist', () => {
should.exist(qb.insert_ignore);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/03-tests-insert_batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const qb = new QueryBuilder();
const test_where = {id:3};
const test_data = [{id:3, name:'Milky Way', type: 'spiral'}, {id:4, name: 'Andromeda', type: 'spiral'}];

describe('insert_batch()', () => {
describe('MSSQL: insert_batch()', () => {
it('should exist', () => {
should.exist(qb.insert_batch);
});
Expand Down
2 changes: 1 addition & 1 deletion test/mssql/03-tests-truncate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = require('chai').expect;
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
const qb = new QueryBuilder();

describe('truncate()', () => {
describe('MSSQL: truncate()', () => {
it('should exist', () => {
should.exist(qb.truncate);
});
Expand Down
4 changes: 2 additions & 2 deletions test/mssql/03-tests-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const test_data_set = [{id:3, name:'Milky Way', type: 'spiral'}, {id:4, name: 'A

// table, data, callback, ignore, suffix

describe('update()', () => {
describe('MSSQL: update()', () => {
it('should exist', () => {
should.exist(qb.update);
});
Expand Down Expand Up @@ -121,6 +121,6 @@ describe('update()', () => {
it('should allow for a LIMITed update', () => {
qb.reset_query();
const sql = qb.limit(10).update('galaxies', test_data, test_where);
sql.should.eql("UPDATE [t] SET [name] = 'Milky Way', [type] = 'spiral' FROM (SELECT TOP 10 * FROM [galaxies] WHERE [id] = 3) [t]");
sql.should.eql("UPDATE [t] SET [name] = 'Milky Way', [type] = 'spiral' FROM (SELECT TOP (10) * FROM [galaxies] WHERE [id] = 3) [t]");
});
});
Loading

0 comments on commit f908251

Please sign in to comment.