Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed May 28, 2020
1 parent bed291a commit c35ddd1
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ const serverWithUrl = {
},
},
};
const serverWithUrlAndSingleHost = {
monitoring: {
ui: {
elasticsearch: {
hosts: 'http://monitoring-cluster.test:9200',
username: 'monitoring-user-internal-test',
password: 'monitoring-p@ssw0rd!-internal-test',
ssl: {},
customHeaders: {
'x-custom-headers-test': 'connection-monitoring',
},
},
},
},
};

const createClient = sinon.stub();
const log = { info: sinon.stub() };
Expand Down Expand Up @@ -111,6 +126,18 @@ describe('Instantiate Client', () => {
expect(createClientOptions.username).to.eql('monitoring-user-internal-test');
expect(createClientOptions.password).to.eql('monitoring-p@ssw0rd!-internal-test');
});

it('should always use an array', () => {
instantiateClient(serverWithUrlAndSingleHost.monitoring.ui.elasticsearch, log, createClient);
const createClusterCall = createClient.getCall(0);
const createClientOptions = createClusterCall.args[1];

sinon.assert.calledOnce(createClient);
expect(createClusterCall.args[0]).to.be('monitoring');
expect(createClientOptions.hosts[0]).to.eql('http://monitoring-cluster.test:9200');
expect(createClientOptions.username).to.eql('monitoring-user-internal-test');
expect(createClientOptions.password).to.eql('monitoring-p@ssw0rd!-internal-test');
});
});

describe('hasMonitoringCluster', () => {
Expand Down

0 comments on commit c35ddd1

Please sign in to comment.