kitejs
Version:
the rpc framework Kite for Node.js
39 lines (35 loc) • 1.51 kB
text/typescript
import {expect} from 'chai';
import {Config} from '../../src/config';
import {Consul} from '../../src/consul';
import {Map} from '../../src/types/lang';
import {Address} from '../../src/protocol/protocol';
describe('Test consul', () => {
it ('with lookup or default', (ok) => {
var client = new Consul();
var addr = new Address('consul.service.byted.org', 2280);
client.get(addr, 'toutiao.passport.session', function (err, data) {
expect(err).to.be.a('null');
expect(data).to.be.an('array').that.not.empty;
expect(data[0]).to.include.all.keys('host', 'port');
ok();
}, 'prod', null, 'lookup', {timeout: 1000});
});
it ('with lookup timeout', (ok) => {
var client = new Consul();
var addr = new Address('consul.service.byted.org', 2280);
client.get(addr, 'toutiao.passport.session', function (err, data) {
expect(err.code).to.be.equal('ETIMEDOUT');
ok();
}, 'prod', null, 'lookup', {timeout: 1});
});
it ('with catelog', (ok) => {
var client = new Consul();
var addr = new Address('consul.service.byted.org', 2280);
client.get(addr, 'toutiao.passport.session', function (err, data) {
expect(err).to.be.a('null');
expect(data).to.be.an('array').that.not.empty;
expect(data[0]).to.include.all.keys('host', 'port');
ok();
}, 'prod', null, 'backlog');
});
});