Updated nodes_to_host callback

Now, it will properly ignore nodes without HTTP enabled, and nodes with addresses that don't match the pattern will not cause all hell to break loose but rather log an error message and cancel the sniff.
Also comes with minor updates to the API.
This commit is contained in:
Spencer Alger
2014-03-18 11:45:59 -07:00
parent 2101e82cb1
commit bfa6c40157
8 changed files with 341 additions and 7 deletions

View File

@ -30,4 +30,24 @@ describe('Nodes to host callback', function () {
});
});
it('ignores hosts that don\'t have an http_host property', function () {
var hosts = callback({
node_id: {
not: 'much of a node'
}
});
expect(hosts.length).to.be(0);
});
it('throws an error when the host property is not formatted properly', function () {
expect(function () {
var hosts = callback({
node_id: {
http_address: 'not actually an http host'
}
});
}).to.throwException(/does not match the expected pattern/);
});
});