Skip to content

Commit

Permalink
[test] Start tests for verifyRunlist
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecki committed May 11, 2013
1 parent 72cfedd commit 3898b21
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
8 changes: 7 additions & 1 deletion test/helpers/mock.js
Expand Up @@ -18,6 +18,7 @@ var systemsDir = path.join(__dirname, '..', 'fixtures'),
sourceDir = path.join(systemsDir, 'tgz');

mock.api = nock('http://api.testquill.com');
mock.config = {};
mock.systems = {};

mock.systems.get = function (api, system) {
Expand All @@ -31,4 +32,9 @@ mock.systems.all = function (api) {
mock.systems.get(api, system);
}
});
};
};

mock.config.servers = function (api, servers) {
api.get('/config/servers')
.reply(200, servers);
};
35 changes: 34 additions & 1 deletion test/remote-dependencies-test.js
Expand Up @@ -90,6 +90,27 @@ function shouldFindCircularRemoteDeps(assertFn) {
}
}

function shouldVerifyRunlist(options, callback) {
return {
topic: function () {
var api = nock('http://api.testquill.com');

mock.config.servers(api, options.servers);
systemJson.remote.verifyRunlist({
runlist: options.runlist,
clusters: options.clusters,
client: composer.createClient({
protocol: 'http',
host: 'api.testquill.com',
port: 80,
auth: {}
}).config
}, this.callback);
},
'should respond with correct servers': callback
};
}

vows.describe('system.json/remote-dependencies').addBatch({
"When using system.json": {
"remote.runlist()": {
Expand Down Expand Up @@ -141,6 +162,18 @@ vows.describe('system.json/remote-dependencies').addBatch({
'm': [ 'complex-circular-deps' ]
});
})
},
'`remote.verifyRunlist()`': {
'no clusters, one dependency': shouldVerifyRunlist({
runlist: [ { name: 'couchdb' } ],
servers: { 'couchdb': [ { public: ['couchdb.net' ] } ]
}
}, function (err, satisfying) {
assert.isNull(err);
assert.deepEqual(satisfying, {
'couchdb': [ { public: ['couchdb.net' ] } ]
});
})
}
}
}).export(module);
}).export(module);

0 comments on commit 3898b21

Please sign in to comment.