Skip to content

Commit cb8a4b0

Browse files
author
Chris Clarke
committed
Adding testing of default constructor/config chain - minimal config now databases.defaultConnStr from env
1 parent e4d2e03 commit cb8a4b0

File tree

9 files changed

+65
-313
lines changed

9 files changed

+65
-313
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ lib-cov
77
*.pid
88
*.gz
99

10+
.idea
1011
pids
1112
logs
1213
results

.idea/libraries/sass_stdlib.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gruntfile.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ module.exports = function (grunt) {
1313
},
1414
src: ["test/**/*.js"]
1515
},
16+
"test-x-unit": {
17+
options: {
18+
reporter: "xunit",
19+
timeout: 10000
20+
},
21+
src: ["test/**/*.js"]
22+
},
1623
filter: {
1724
src: ["test/**/*_test.js"],
1825
options: {
@@ -67,6 +74,7 @@ module.exports = function (grunt) {
6774

6875
// Default task.
6976
grunt.registerTask('default', ['jshint', 'mochaTest:test']);
77+
grunt.registerTask('bamboo', ['jshint', 'mochaTest:test-x-unit']);
7078
grunt.registerTask('clean', ['jshint', 'jsbeautifier:modify']);
7179
grunt.registerTask('verify', ['jshint', 'jsbeautifier:verify']);
7280
grunt.registerTask('filtertest', 'Runs tests based on pattern specified', function (taskName, pattern) {

lib/config.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ var loc = process.env.TRIPOD_CONFIG,
22
fs = require('fs'),
33
conf = require('nconf');
44

5-
conf.file({ file: loc });
5+
conf.env()
6+
.file({ file: loc });
67

78
conf.defaults({
89
"namespaces":{
9-
"rdfs":"http://www.w3.org/2000/01/rdf-schema#"
10+
"rdf":"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
11+
"rdfs":"http://www.w3.org/2000/01/rdf-schema#",
12+
"changeset":"http://purl.org/vocab/changeset/schema#"
1013
},
1114
"defaultContext" : "http://talis.com/",
12-
"view_specifications" : [],
13-
"table_specifications" : []
15+
"databases" : {
16+
"defaultConnStr" : "mongodb://localhost"
17+
}
1418
});
1519

1620
exports = module.exports = conf;

lib/tripod.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ var TripleGraph = require('./graph');
88
*/
99
var Tripod = function(dbName,collectionName) {
1010
this._config = config;
11-
this._connStr = config.get("databases:"+dbName+":connStr")+"/"+dbName;
11+
if (config.get("databases:"+dbName+":connStr")) {
12+
this._connStr = config.get("databases:"+dbName+":connStr")+"/"+dbName;
13+
} else {
14+
this._connStr = config.get("databases:defaultConnStr")+"/"+dbName;
15+
}
1216
this._collectionName = collectionName;
1317
this._collection = null;
1418
this._viewsCollection = null;

test/conf.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
process.env.TRIPOD_CONFIG = './test/conf.json';
2+
process.env["databases:defaultConnStr"] = 'mongodb://foobarbaz';
3+
require("../lib/config");

0 commit comments

Comments
 (0)