Skip to content
Permalink
Browse files

[test] Add more `verifyRunlist` tests

  • Loading branch information...
mmalecki committed May 12, 2013
1 parent 3898b21 commit 1fe18456f40c6f27267244e978bc648affdb97e1
Showing with 49 additions and 3 deletions.
  1. +7 −2 test/helpers/mock.js
  2. +42 −1 test/remote-dependencies-test.js
@@ -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);
};
@@ -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,
@@ -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' ] } ]
});
})
}
}

0 comments on commit 1fe1845

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.