Skip to content

Commit

Permalink
initial commit, with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpacker committed Sep 25, 2013
0 parents commit 6f6b66f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
npm-debug.log
.DS_Store
node_modules
28 changes: 28 additions & 0 deletions package.json
@@ -0,0 +1,28 @@
{
"name": "cascading-service-config",
"version": "0.1.0",
"description": "dry configuration for a multi-service system",
"main": "csc.js",
"scripts": {
"test": "mocha -R spec"
},
"repository": {
"type": "git",
"url": "http://www.github.com/brikteknologier/cascading-service-config"
},
"keywords": [
"service",
"config",
"cascading",
"inherit",
"inheritance",
"protypical",
"protypal",
"dry"
],
"author": "Jon packer",
"license": "MIT",
"devDependencies": {
"mocha": "~1.13.0"
}
}
50 changes: 50 additions & 0 deletions test/test.js
@@ -0,0 +1,50 @@
var csc = require('../');
var assert = require('assert');

var config = {
"neo4j": "http://localhost:7474/",
"internalServiceHostname": "localhost",
"internalServiceProtocol": "http",
"stoutmeal": {
"cookie": "authKey",
"store": {
"type": "redis",
"host": "localhost",
"port": 6379
}
},
"stout": {
"defaultUrl": "http://lol.com",
"port": 6005,
"cookieDomain": "localhost"
},
"sahti": {
"port": 6003
}
};

describe('CSC', function() {
it('should access basic config settings', function() {
var config = csc(config, 'stout');
assert.equal(config.port, 6005);
assert.equal(config.cookieDomain, "localhost");
assert.equal(config.defaultUrl, "http://lol.com");
});
it('should inherit values on the root object', function() {
var config = csc(config, 'stout');
assert.equal(config.neo4j, 'http://localhost:7474');
});
it('should inherit non-service objects on the root object', function() {
var config = csc(config, 'stout');
assert.equal(config.stoutmeal.cookie, 'authKey');
assert.equal(config.stoutmeal.store.type, 'redis');
});
it('should transform root service objects to their location', function() {
var config = csc(config, 'stout');
assert.equal(config.sahti, 'http://localhost:6003');
});
it('non-service root objects should also inherit service locations', function() {
var config = csc(config, 'stout');
assert.equal(config.stoutmeal.stout, 'http://localhost:6005');
});
});

0 comments on commit 6f6b66f

Please sign in to comment.