[transport] expose a method for updating the host list
This commit is contained in:
@ -15,15 +15,6 @@ describe('Connection Abstract', function () {
|
||||
expect(conn.host).to.be(host);
|
||||
});
|
||||
|
||||
it('constructs with string host using Host constructor', function(){
|
||||
var host = 'localhost';
|
||||
var port = 9200;
|
||||
var hostUrl = host+':'+port;
|
||||
var conn = new ConnectionAbstract(hostUrl);
|
||||
expect(conn.host.host).to.be(host);
|
||||
expect(conn.host.port).to.be(port);
|
||||
});
|
||||
|
||||
it('requires a valid host', function () {
|
||||
expect(function () {
|
||||
new ConnectionAbstract();
|
||||
|
||||
@ -807,6 +807,43 @@ describe('Transport Class', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setHosts', function () {
|
||||
it('accepts strings, host objects, and host configs', function () {
|
||||
|
||||
var trans = new Transport({ suggestCompression: true });
|
||||
stub(trans.connectionPool, 'setHosts');
|
||||
|
||||
trans.setHosts([
|
||||
{ host: 'first.server', port: 9200 },
|
||||
'http://second.server:9200',
|
||||
new Host('http://third.server:9200')
|
||||
]);
|
||||
|
||||
sinon.assert.calledOnce(trans.connectionPool.setHosts);
|
||||
var host, hosts = trans.connectionPool.setHosts.firstCall.args[0];
|
||||
|
||||
expect(hosts).to.have.length(3);
|
||||
|
||||
host = hosts.shift();
|
||||
expect(host).to.be.a(Host);
|
||||
expect(host.host).to.eql('first.server');
|
||||
expect(host.port).to.eql(9200);
|
||||
expect(host.suggestCompression).to.be(true);
|
||||
|
||||
host = hosts.shift();
|
||||
expect(host).to.be.a(Host);
|
||||
expect(host.host).to.eql('second.server');
|
||||
expect(host.port).to.eql(9200);
|
||||
expect(host.suggestCompression).to.be(true);
|
||||
|
||||
host = hosts.shift();
|
||||
expect(host).to.be.a(Host);
|
||||
expect(host.host).to.eql('third.server');
|
||||
expect(host.port).to.eql(9200);
|
||||
expect(host.suggestCompression).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#close', function () {
|
||||
it('proxies the call to it\'s log and connection pool', function () {
|
||||
var tran = new Transport();
|
||||
|
||||
Reference in New Issue
Block a user