Skip to content

Commit

Permalink
Adding testing of default constructor/config chain - minimal config n…
Browse files Browse the repository at this point in the history
…ow databases.defaultConnStr from env
  • Loading branch information
Chris Clarke committed Mar 11, 2014
1 parent e4d2e03 commit cb8a4b0
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 313 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ lib-cov
*.pid
*.gz

.idea
pids
logs
results
Expand Down
8 changes: 8 additions & 0 deletions .idea/libraries/sass_stdlib.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ module.exports = function (grunt) {
},
src: ["test/**/*.js"]
},
"test-x-unit": {
options: {
reporter: "xunit",
timeout: 10000
},
src: ["test/**/*.js"]
},
filter: {
src: ["test/**/*_test.js"],
options: {
Expand Down Expand Up @@ -67,6 +74,7 @@ module.exports = function (grunt) {

// Default task.
grunt.registerTask('default', ['jshint', 'mochaTest:test']);
grunt.registerTask('bamboo', ['jshint', 'mochaTest:test-x-unit']);
grunt.registerTask('clean', ['jshint', 'jsbeautifier:modify']);
grunt.registerTask('verify', ['jshint', 'jsbeautifier:verify']);
grunt.registerTask('filtertest', 'Runs tests based on pattern specified', function (taskName, pattern) {
Expand Down
12 changes: 8 additions & 4 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ var loc = process.env.TRIPOD_CONFIG,
fs = require('fs'),
conf = require('nconf');

conf.file({ file: loc });
conf.env()
.file({ file: loc });

conf.defaults({
"namespaces":{
"rdfs":"http://www.w3.org/2000/01/rdf-schema#"
"rdf":"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs":"http://www.w3.org/2000/01/rdf-schema#",
"changeset":"http://purl.org/vocab/changeset/schema#"
},
"defaultContext" : "http://talis.com/",
"view_specifications" : [],
"table_specifications" : []
"databases" : {
"defaultConnStr" : "mongodb://localhost"
}
});

exports = module.exports = conf;
6 changes: 5 additions & 1 deletion lib/tripod.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ var TripleGraph = require('./graph');
*/
var Tripod = function(dbName,collectionName) {
this._config = config;
this._connStr = config.get("databases:"+dbName+":connStr")+"/"+dbName;
if (config.get("databases:"+dbName+":connStr")) {
this._connStr = config.get("databases:"+dbName+":connStr")+"/"+dbName;
} else {
this._connStr = config.get("databases:defaultConnStr")+"/"+dbName;
}
this._collectionName = collectionName;
this._collection = null;
this._viewsCollection = null;
Expand Down
3 changes: 3 additions & 0 deletions test/conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
process.env.TRIPOD_CONFIG = './test/conf.json';
process.env["databases:defaultConnStr"] = 'mongodb://foobarbaz';
require("../lib/config");
Loading

0 comments on commit cb8a4b0

Please sign in to comment.