Permalink
Browse files

initial commit, with tests

  • Loading branch information...
0 parents commit 6f6b66f21be034cabd1d1c80fa8b8aa76485b246 @jonpacker jonpacker committed Sep 25, 2013
Showing with 81 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +28 −0 package.json
  3. +50 −0 test/test.js
@@ -0,0 +1,3 @@
+npm-debug.log
+.DS_Store
+node_modules
@@ -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"
+ }
+}
@@ -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.