Skip to content

Commit 7d1cb98

Browse files
committed
Mongodb
1 parent 5dfbe1c commit 7d1cb98

File tree

2 files changed

+133
-126
lines changed

2 files changed

+133
-126
lines changed

test/integration/association-hasone.js

Lines changed: 70 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
var ORM = require('../../');
2-
var helper = require('../support/spec_helper');
3-
var should = require('should');
4-
var async = require('async');
5-
var _ = require('lodash');
1+
var ORM = require('../../');
2+
var helper = require('../support/spec_helper');
3+
var should = require('should');
4+
var async = require('async');
5+
var _ = require('lodash');
6+
var common = require('../common');
7+
var protocol = common.protocol();
68

79
describe("hasOne", function() {
810
var db = null;
@@ -379,89 +381,91 @@ describe("hasOne", function() {
379381
});
380382
});
381383

382-
describe("mapsTo", function () {
383-
describe("with `mapsTo` set via `hasOne`", function () {
384-
var leaf = null;
384+
if (protocol != "mongodb") {
385+
describe("mapsTo", function () {
386+
describe("with `mapsTo` set via `hasOne`", function () {
387+
var leaf = null;
385388

386-
before(setup());
389+
before(setup());
387390

388-
before(function (done) {
389-
Leaf.create({ size: 444, stalkId: stalkId, holeId: holeId }, function (err, lf) {
390-
should.not.exist(err);
391-
leaf = lf;
392-
done();
391+
before(function (done) {
392+
Leaf.create({ size: 444, stalkId: stalkId, holeId: holeId }, function (err, lf) {
393+
should.not.exist(err);
394+
leaf = lf;
395+
done();
396+
});
393397
});
394-
});
395398

396-
it("should have correct fields in the DB", function (done) {
397-
var sql = db.driver.query.select()
398-
.from('leaf')
399-
.select('size', 'stalk_id')
400-
.where({ size: 444 })
401-
.build();
399+
it("should have correct fields in the DB", function (done) {
400+
var sql = db.driver.query.select()
401+
.from('leaf')
402+
.select('size', 'stalk_id')
403+
.where({ size: 444 })
404+
.build();
402405

403-
db.driver.execQuery(sql, function (err, rows) {
404-
should.not.exist(err);
406+
db.driver.execQuery(sql, function (err, rows) {
407+
should.not.exist(err);
405408

406-
should.equal(rows[0].size, 444);
407-
should.equal(rows[0].stalk_id, 1);
409+
should.equal(rows[0].size, 444);
410+
should.equal(rows[0].stalk_id, 1);
408411

409-
done();
410-
});
411-
});
412+
done();
413+
});
414+
});
412415

413-
it("should get parent", function (done) {
414-
leaf.getStalk(function (err, stalk) {
415-
should.not.exist(err);
416+
it("should get parent", function (done) {
417+
leaf.getStalk(function (err, stalk) {
418+
should.not.exist(err);
416419

417-
should.exist(stalk);
418-
should.equal(stalk.id, stalkId);
419-
should.equal(stalk.length, 20);
420-
done();
420+
should.exist(stalk);
421+
should.equal(stalk.id, stalkId);
422+
should.equal(stalk.length, 20);
423+
done();
424+
});
421425
});
422426
});
423-
});
424427

425-
describe("with `mapsTo` set via property definition", function () {
426-
var leaf = null;
428+
describe("with `mapsTo` set via property definition", function () {
429+
var leaf = null;
427430

428-
before(setup());
431+
before(setup());
429432

430-
before(function (done) {
431-
Leaf.create({ size: 444, stalkId: stalkId, holeId: holeId }, function (err, lf) {
432-
should.not.exist(err);
433-
leaf = lf;
434-
done();
433+
before(function (done) {
434+
Leaf.create({ size: 444, stalkId: stalkId, holeId: holeId }, function (err, lf) {
435+
should.not.exist(err);
436+
leaf = lf;
437+
done();
438+
});
435439
});
436-
});
437440

438-
it("should have correct fields in the DB", function (done) {
439-
var sql = db.driver.query.select()
440-
.from('leaf')
441-
.select('size', 'hole_id')
442-
.where({ size: 444 })
443-
.build();
441+
it("should have correct fields in the DB", function (done) {
442+
var sql = db.driver.query.select()
443+
.from('leaf')
444+
.select('size', 'hole_id')
445+
.where({ size: 444 })
446+
.build();
444447

445-
db.driver.execQuery(sql, function (err, rows) {
446-
should.not.exist(err);
448+
db.driver.execQuery(sql, function (err, rows) {
449+
should.not.exist(err);
447450

448-
should.equal(rows[0].size, 444);
449-
should.equal(rows[0].hole_id, 1);
451+
should.equal(rows[0].size, 444);
452+
should.equal(rows[0].hole_id, 1);
450453

451-
done();
452-
});
453-
});
454+
done();
455+
});
456+
});
454457

455-
it("should get parent", function (done) {
456-
leaf.getHole(function (err, hole) {
457-
should.not.exist(err);
458+
it("should get parent", function (done) {
459+
leaf.getHole(function (err, hole) {
460+
should.not.exist(err);
458461

459-
should.exist(hole);
460-
should.equal(hole.id, stalkId);
461-
should.equal(hole.width, 3);
462-
done();
462+
should.exist(hole);
463+
should.equal(hole.id, stalkId);
464+
should.equal(hole.width, 3);
465+
done();
466+
});
463467
});
464468
});
465469
});
466-
});
470+
};
467471
});

test/integration/orm-exports.js

Lines changed: 63 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ var sqlite = require('sqlite3');
33
var pg = require('pg');
44
var should = require('should');
55
var helper = require('../support/spec_helper');
6-
var common = require('../common');
76
var ORM = require('../../');
7+
var common = require('../common');
8+
var protocol = common.protocol();
89

910
describe("ORM", function() {
1011
describe("when loaded", function () {
@@ -240,77 +241,79 @@ describe("ORM.connect()", function () {
240241
});
241242
});
242243

243-
describe("query options", function () {
244-
it("should understand pool `'false'` from query string", function (done) {
245-
var connString = common.getConnectionString() + "debug=false&pool=false";
246-
ORM.connect(connString, function (err, db) {
247-
should.not.exist(err);
248-
should.strictEqual(db.driver.opts.pool, false);
249-
should.strictEqual(db.driver.opts.debug, false);
250-
done();
244+
if (protocol != 'mongodb') {
245+
describe("query options", function () {
246+
it("should understand pool `'false'` from query string", function (done) {
247+
var connString = common.getConnectionString() + "debug=false&pool=false";
248+
ORM.connect(connString, function (err, db) {
249+
should.not.exist(err);
250+
should.strictEqual(db.driver.opts.pool, false);
251+
should.strictEqual(db.driver.opts.debug, false);
252+
done();
253+
});
251254
});
252-
});
253255

254-
it("should understand pool `'0'` from query string", function (done) {
255-
var connString = common.getConnectionString() + "debug=0&pool=0";
256-
ORM.connect(connString, function (err, db) {
257-
should.not.exist(err);
258-
should.strictEqual(db.driver.opts.pool, false);
259-
should.strictEqual(db.driver.opts.debug, false);
260-
done();
256+
it("should understand pool `'0'` from query string", function (done) {
257+
var connString = common.getConnectionString() + "debug=0&pool=0";
258+
ORM.connect(connString, function (err, db) {
259+
should.not.exist(err);
260+
should.strictEqual(db.driver.opts.pool, false);
261+
should.strictEqual(db.driver.opts.debug, false);
262+
done();
263+
});
261264
});
262-
});
263265

264-
it("should understand pool `'true'` from query string", function (done) {
265-
var connString = common.getConnectionString() + "debug=true&pool=true";
266-
ORM.connect(connString, function (err, db) {
267-
should.not.exist(err);
268-
should.strictEqual(db.driver.opts.pool, true);
269-
should.strictEqual(db.driver.opts.debug, true);
270-
done();
266+
it("should understand pool `'true'` from query string", function (done) {
267+
var connString = common.getConnectionString() + "debug=true&pool=true";
268+
ORM.connect(connString, function (err, db) {
269+
should.not.exist(err);
270+
should.strictEqual(db.driver.opts.pool, true);
271+
should.strictEqual(db.driver.opts.debug, true);
272+
done();
273+
});
271274
});
272-
});
273275

274-
it("should understand pool `'1'` from query string", function (done) {
275-
var connString = common.getConnectionString() + "debug=1&pool=1";
276-
ORM.connect(connString, function (err, db) {
277-
should.not.exist(err);
278-
should.strictEqual(db.driver.opts.pool, true);
279-
should.strictEqual(db.driver.opts.debug, true);
280-
done();
276+
it("should understand pool `'1'` from query string", function (done) {
277+
var connString = common.getConnectionString() + "debug=1&pool=1";
278+
ORM.connect(connString, function (err, db) {
279+
should.not.exist(err);
280+
should.strictEqual(db.driver.opts.pool, true);
281+
should.strictEqual(db.driver.opts.debug, true);
282+
done();
283+
});
281284
});
282-
});
283285

284-
it("should understand pool `false` from query options", function (done) {
285-
var connOpts = _.extend(common.getConfig(), {
286-
protocol: common.protocol(),
287-
query: {
288-
pool: false, debug: false
289-
}
290-
});
291-
ORM.connect(connOpts, function (err, db) {
292-
should.not.exist(err);
293-
should.strictEqual(db.driver.opts.pool, false);
294-
should.strictEqual(db.driver.opts.debug, false);
295-
done();
286+
it("should understand pool `true` from query options", function (done) {
287+
var connOpts = _.extend(common.getConfig(), {
288+
protocol: common.protocol(),
289+
query: {
290+
pool: true, debug: true
291+
}
292+
});
293+
ORM.connect(connOpts, function (err, db) {
294+
should.not.exist(err);
295+
should.strictEqual(db.driver.opts.pool, true);
296+
should.strictEqual(db.driver.opts.debug, true);
297+
done();
298+
});
296299
});
297-
});
298300

299-
it("should understand pool `true` from query options", function (done) {
300-
var connOpts = _.extend(common.getConfig(), {
301-
protocol: common.protocol(),
302-
query: {
303-
pool: true, debug: true
304-
}
305-
});
306-
ORM.connect(connOpts, function (err, db) {
307-
should.not.exist(err);
308-
should.strictEqual(db.driver.opts.pool, true);
309-
should.strictEqual(db.driver.opts.debug, true);
310-
done();
301+
it("should understand pool `false` from query options", function (done) {
302+
var connOpts = _.extend(common.getConfig(), {
303+
protocol: common.protocol(),
304+
query: {
305+
pool: false, debug: false
306+
}
307+
});
308+
ORM.connect(connOpts, function (err, db) {
309+
should.not.exist(err);
310+
should.strictEqual(db.driver.opts.pool, false);
311+
should.strictEqual(db.driver.opts.debug, false);
312+
done();
313+
});
311314
});
312315
});
313-
});
316+
}
314317
});
315318

316319
describe("ORM.use()", function () {

0 commit comments

Comments
 (0)