Skip to content

Commit

Permalink
test(config): fix config
Browse files Browse the repository at this point in the history
  • Loading branch information
FGRibreau committed Mar 29, 2015
1 parent 4416c37 commit 4e9d467
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ etc/*.pid
test_results
.env
dump.rdb
test/fixtures/*.json
9 changes: 4 additions & 5 deletions lib/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@ var fs = require('fs');
var path = require('path');

describe('config', function () {
var Config;
var Config, config;

beforeEach(function (done) {
delete process.env.REDIS_URI;
delete process.env.REDIS_AUTH;
Config = configFactory(console);
config = new Config(path.resolve(__dirname, '../test/fixtures/redsmin_default.json'));
done();
});

it('should return a configuration', function () {
var config = new Config(path.resolve(__dirname, '../test/fixtures/redsmin_default.json'));
t.strictEqual(config.redis.auth, null);
t.strictEqual(config.redis.uri, 'redis://127.0.0.1:6379');

t.strictEqual(config.redsmin.key, '5331e06500617e0b0a0000aa');
t.strictEqual(config.redsmin.key, '5331e06500617e0b090000aa');
t.strictEqual(config.redsmin.port, 993);
t.strictEqual(config.redsmin.hostname, 'ssl.redsmin.com');
});

it('should use env vars if defined', function () {
process.env.REDIS_URI = '/tmp/redis.sock';
process.env.REDIS_AUTH = 'aaaa';
var config = new Config(path.resolve(__dirname, '../test/fixtures/redsmin_default.json'));
config = new Config(path.resolve(__dirname, '../test/fixtures/redsmin_default.json'));
t.strictEqual(config.redis.uri, process.env.REDIS_URI);
t.strictEqual(config.redis.auth, process.env.REDIS_AUTH);
});
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/redsmin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"key":"5331e06500617e0b090000aa","redis":"redis://127.0.0.1:6379","auth":"aa"}
5 changes: 5 additions & 0 deletions test/fixtures/redsmin_default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"key": "5331e06500617e0b090000aa",
"redis": "redis://127.0.0.1:6379",
"auth": ""
}

0 comments on commit 4e9d467

Please sign in to comment.