-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.js
49 lines (41 loc) · 1.13 KB
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var MetricClient = require('./index.js').MetricClient;
var net = require('net');
var server;
var serverLog = '';
var port = 9001;
module.exports.setUp = function(callback) {
serverLog = '';
server = net.createServer(function(c) {
console.log('connected');
c.on('end', function() {
console.log('disconnected');
});
});
server.listen(port, function() {
callback();
});
};
module.exports.tearDown = function(callback) {
server.close();
callback();
};
module.exports.checkBasicMetricReporting = function(test) {
metricClient = new MetricClient('localhost', port);
metricClient.report({applicationName: 'testApp', metricName: 'testMetric', value: 0}, function (err) {
if(err) {
test.fail();
return;
}
test.done();
});
};
module.exports.checkIncompleteMetricReporting = function(test) {
metricClient = new MetricClient('localhost', port);
metricClient.report({applicationName: 'testApp', value: 0}, function (err) {
if(err) {
test.done();
return;
}
test.fail();
});
};