Skip to content

Commit

Permalink
[test] Add more verifyRunlist tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecki committed May 12, 2013
1 parent 3898b21 commit 1fe1845
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
9 changes: 7 additions & 2 deletions test/helpers/mock.js
Expand Up @@ -34,7 +34,12 @@ mock.systems.all = function (api) {
});
};

mock.config.servers = function (api, servers) {
api.get('/config/servers')
mock.config.servers = function (api, cluster, servers) {
if (typeof cluster === 'object') {
servers = cluster;
cluster = null;
}

api.get('/config/servers' + (cluster ? ('/' + cluster) : ''))
.reply(200, servers);
};
43 changes: 42 additions & 1 deletion test/remote-dependencies-test.js
Expand Up @@ -95,7 +95,15 @@ function shouldVerifyRunlist(options, callback) {
topic: function () {
var api = nock('http://api.testquill.com');

mock.config.servers(api, options.servers);
if (options.clusters) {
Object.keys(options.servers).forEach(function (cluster) {
mock.config.servers(api, cluster, options.servers[cluster]);
});
}
else {
mock.config.servers(api, options.servers);
}

systemJson.remote.verifyRunlist({
runlist: options.runlist,
clusters: options.clusters,
Expand Down Expand Up @@ -173,6 +181,39 @@ vows.describe('system.json/remote-dependencies').addBatch({
assert.deepEqual(satisfying, {
'couchdb': [ { public: ['couchdb.net' ] } ]
});
}),
'not satisfied dependency': shouldVerifyRunlist({
runlist: [ { name: 'couchdb' }, { name: 'redis' } ],
servers: { 'redis': [ { public: ['redis.net' ] } ]
}
}, function (err, satisfying) {
assert(err);
assert.deepEqual(err.missing, [ 'couchdb' ]);
}),
'one cluster': shouldVerifyRunlist({
runlist: [ { name: 'couchdb' } ],
clusters: ['composer'],
servers: {
composer: { couchdb: [ { public: ['couchdb.net'] } ] }
}
}, function (err, satisfying) {
assert.isNull(err);
assert.deepEqual(satisfying, {
'couchdb': [ { public: ['couchdb.net' ] } ]
});
}),
'duplicate servers in two clusters': shouldVerifyRunlist({
runlist: [ { name: 'couchdb' } ],
clusters: ['composer', 'conservatory'],
servers: {
composer: { couchdb: [ { public: ['couchdb.net'] } ] },
conservatory: { couchdb: [ { public: ['couchdb.net'] } ] }
}
}, function (err, satisfying) {
assert.isNull(err);
assert.deepEqual(satisfying, {
'couchdb': [ { public: ['couchdb.net' ] } ]
});
})
}
}
Expand Down

0 comments on commit 1fe1845

Please sign in to comment.