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

Commit

Permalink
test: add new replay-buffer bailout test
Browse files Browse the repository at this point in the history
  • Loading branch information
skenqbx committed Apr 26, 2015
1 parent 254dd1b commit 8ba0ce7
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/test-http-replay-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,60 @@ suite('http:replay-buffer', function() {
});


test('bailout', function(done) {
onrequest = function(request, response) {
var body = [];

request.on('readable', function() {
var data = request.read();
if (data) {
body.push(data);
}
});

request.on('end', function() {
body = Buffer.concat(body);
assert.strictEqual(body.toString(), 'abcdefghijklmnopqr');
response.end('pong');
});
};

var call = rail.call({
proto: 'http',
port: common.port,
method: 'PUT',
maxReplayBuffer: 12
}, function(response) {
var body = [];

assert.strictEqual(response.statusCode, 200);

response.on('readable', function() {
var data = response.read();
if (data) {
body.push(data);
}
});

response.on('end', function() {
body = Buffer.concat(body);
assert.strictEqual(body.length, 4);
assert.strictEqual(body.toString(), 'pong');
assert.strictEqual(call._buffer, null);

done();
});
});

call.__buffer();

call.write('abcdef');
call.write('ghijkl');

call.end('mnopqr');
});


test('abort', function() {
onrequest = function(request, response) {
};
Expand Down

0 comments on commit 8ba0ce7

Please sign in to comment.