Windshaft-cartodb/test/unit/ported/stats-client-test.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
2019-10-07 17:29:07 +08:00
require('../../support/test-helper');
2015-09-15 01:07:53 +08:00
var assert = require('assert');
2019-10-07 17:29:07 +08:00
var StatsClient = require('../../../lib/stats/client');
2015-09-15 01:07:53 +08:00
describe('stats client', function() {
var statsInstance;
before(function() {
statsInstance = StatsClient.instance;
StatsClient.instance = null;
});
after(function() {
StatsClient.instance = statsInstance;
});
it('reports errors when they repeat', function(done) {
var WADUS_ERROR = 'wadus_error';
var statsClient = StatsClient.getInstance({ host: '127.0.0.1', port: 8033 });
statsClient.socket.emit('error', 'other_error');
assert.ok(statsClient.last_error);
assert.equal(statsClient.last_error.msg, 'other_error');
assert.ok(!statsClient.last_error.interval);
statsClient.socket.emit('error', WADUS_ERROR);
assert.ok(statsClient.last_error);
assert.equal(statsClient.last_error.msg, WADUS_ERROR);
assert.ok(!statsClient.last_error.interval);
statsClient.socket.emit('error', WADUS_ERROR);
assert.ok(statsClient.last_error);
assert.equal(statsClient.last_error.msg, WADUS_ERROR);
assert.ok(statsClient.last_error.interval);
done();
});
});