Commit f42082de authored by Alan Szlosek's avatar Alan Szlosek

automate bits of the digest tests

parent 3573642e
......@@ -26,7 +26,15 @@ tap.test('digest.second', function(test) {
});
tap.test('digest.five-second', function(test) {
test.plan(2);
test.plan(3);
var messageTypes = {
'456': [
{ message: 'First', requestId: 1 },
{ message: 'Second', requestId: 2 },
{ message: 'Third', requestId: 3 }
]
};
var start = moment().unix();
var callback = function(counts, cache) {
......@@ -34,14 +42,22 @@ tap.test('digest.five-second', function(test) {
test.ok(now.getSeconds() == 0 || now.getSeconds() % 5 == 0);
// Make sure we've seen two instances of message id 123
test.equal(counts[456], 2);
test.equal(counts[456], messageTypes[456].length);
test.same(cache, messageTypes);
digest.stop();
test.end();
};
// This pattern matches "every 5 seconds"
var digest = new Harbinger.Digest(true, /(\d0|\d5)\.\d{1,3}Z/, 10, callback);
digest.add(456, {message: 'Test'});
digest.add(456, {message: 'Another'});
for (var messageId in messageTypes) {
var messages = messageTypes[messageId];
for (var i = 0; i < messages.length; i++) {
digest.add(messageId, messages[i]);
}
}
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment