Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review fixes 2.0.
  • Loading branch information
Kasher committed Jul 11, 2017
commit fd89a7e5707574553af9c75492a6ebb7b91b9293
19 changes: 9 additions & 10 deletions test/parallel/test-http-outgoing-finish-writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ const common = require('../common');
const assert = require('assert');
const http = require('http');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a little comment explaining what this test is about here?

// Verify that after calling end() on an `OutgoingMessage` (or a type that
// inherits from `OutgoingMessage`), its `writable` property is set to false.

const server = http.createServer(common.mustCall(function(req, res) {
assert(res.writable, 'Res should be writable when it is received \
and opened.');
assert(!res.finished, 'Res shouldn\'t be finished when it is received \
and opened.');
assert.strictEqual(res.writable, true);
assert.strictEqual(res.finished, false);
res.end();
assert(!res.writable, 'Res shouldn\'t be writable after it was closed.');
assert(res.finished, 'Res should be finished after it was closed.');
assert.strictEqual(res.writable, false);
assert.strictEqual(res.finished, true);

server.close();
}));
Expand All @@ -24,9 +25,7 @@ server.on('listening', common.mustCall(function() {
path: '/'
});

assert(clientRequest.writable, 'ClientRequest should be writable when \
it is created.');
assert.strictEqual(clientRequest.writable, true);
clientRequest.end();
assert(!clientRequest.writable, 'ClientRequest shouldn\'t be writable \
after it was closed.');
assert.strictEqual(clientRequest.writable, false);
}));
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ function MyStream() {
util.inherits(MyStream, stream);

const server = http.createServer(common.mustCall(function(req, res) {
console.log('Got a request, piping a stream to it.');
const myStream = new MyStream();
myStream.pipe(res);

process.nextTick(() => {
console.log('Closing response.');
process.nextTick(common.mustCall(() => {
res.end();
myStream.emit('data', 'some data');

// If we got here - 'write after end' wasn't raised and the test passed.
process.nextTick(() => server.close());
});
process.nextTick(common.mustCall(() => server.close()));
}));
}));

server.listen(0);
Expand Down