Skip to content

Commit 94679e2

Browse files
committed
Adds proper support for mongodb in test framework
1 parent dce0889 commit 94679e2

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ node_js:
66
before_script:
77
- mysql -e 'create database orm_test;'
88
- psql -c 'create database orm_test;' -U postgres
9+
services:
10+
- mongodb

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ test:
33
ORM_PROTOCOL=postgres node test/run
44
ORM_PROTOCOL=redshift node test/run
55
ORM_PROTOCOL=sqlite node test/run
6+
ORM_PROTOCOL=mongodb node test/run
67

78
coverage: cov
89

test/common.js

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ common.getConfig = function () {
2727
return { user: "postgres", host: "localhost", database: "orm_test" };
2828
case 'sqlite':
2929
return {};
30+
case 'mongodb':
31+
return { host: "localhost", database: "test" };
3032
default:
3133
throw new Error("Unknown protocol");
3234
}
@@ -47,6 +49,8 @@ common.getConnectionString = function () {
4749
return 'postgres://postgres@localhost/orm_test';
4850
case 'sqlite':
4951
return 'sqlite://';
52+
case 'mongodb':
53+
return 'mongodb://localhost/test';
5054
default:
5155
throw new Error("Unknown protocol");
5256
}

test/run.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ var mocha = new Mocha({
99
runTests();
1010

1111
function runTests() {
12-
fs.readdirSync(location).filter(function(file){
12+
fs.readdirSync(location).filter(function (file) {
1313
return file.substr(-3) === '.js';
14-
}).forEach(function(file){
14+
}).forEach(function (file) {
15+
if (!shouldRunTest(file)) return;
16+
1517
mocha.addFile(
1618
path.join(location, file)
1719
);
@@ -24,3 +26,14 @@ function runTests() {
2426
process.exit(failures);
2527
});
2628
}
29+
30+
function shouldRunTest(file) {
31+
var name = file.substr(0, file.length - 3);
32+
var proto = process.env.ORM_PROTOCOL;
33+
34+
if (proto == "mongodb" && [ "association-hasmany-extra", "association-hasmany",
35+
"model-aggregate",
36+
"property-lazyload", "property-number-size" ].indexOf(name) >= 0) return false;
37+
38+
return true;
39+
}

0 commit comments

Comments
 (0)