Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
test: add retry plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skenqbx committed Apr 23, 2015
1 parent 259b01e commit 2432c70
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test/test-http-retry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use strict';
/* global suite: false, setup: false, test: false,
teardown: false, suiteSetup: false, suiteTeardown: false */
var assert = require('assert');
var common = require('./common');
var http = require('http');
var RAIL = require('../');


suite('http:retry', function() {
var rail, server;
var onrequest;

var listener = function(request, response) {
if (typeof onrequest === 'function') {
onrequest(request, response);
}
};


suiteSetup(function(done) {
rail = new RAIL();
rail.use('retry', {
limit: 3,
interval: 20
});

server = http.createServer(listener);
server.listen(common.port, done);
});


test('call', function(done) {
var retries = 0;

rail.call({
proto: 'http',
port: 55555
}).on('error', function(err) {
assert(err);
assert.strictEqual(retries, 3);
assert.strictEqual(err.code, 'ECONNREFUSED');
done();
}).on('retry', function(options) {
assert(options);
assert(options.retry);
++retries;
}).end();
});


suiteTeardown(function(done) {
server.close(done);
});
});

0 comments on commit 2432c70

Please sign in to comment.