Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the
bunyan
CLI to not duplicate the "HTTP/1.1 ..." status line …
…when serializing a "res" field. (#444)
- Loading branch information
Showing
5 changed files
with
95 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2017, Trent Mick. | ||
* | ||
* Test the bunyan CLI's handling of the "res" field. | ||
*/ | ||
|
||
var exec = require('child_process').exec; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var _ = require('util').format; | ||
var vasync = require('vasync'); | ||
|
||
// node-tap API | ||
if (require.cache[__dirname + '/tap4nodeunit.js']) | ||
delete require.cache[__dirname + '/tap4nodeunit.js']; | ||
var tap4nodeunit = require('./tap4nodeunit.js'); | ||
var after = tap4nodeunit.after; | ||
var before = tap4nodeunit.before; | ||
var test = tap4nodeunit.test; | ||
|
||
|
||
// ---- globals | ||
|
||
var BUNYAN = path.resolve(__dirname, '../bin/bunyan'); | ||
|
||
|
||
// ---- tests | ||
|
||
test('res with "header" string (issue #444)', function (t) { | ||
var expect = [ | ||
/* BEGIN JSSTYLED */ | ||
'[2017-08-02T22:37:34.798Z] INFO: res-header/76488 on danger0.local: response sent', | ||
' HTTP/1.1 200 OK', | ||
' Foo: bar', | ||
' Date: Wed, 02 Aug 2017 22:37:34 GMT', | ||
' Connection: keep-alive', | ||
' Content-Length: 21' | ||
/* END JSSTYLED */ | ||
].join('\n') + '\n'; | ||
exec(_('%s %s/corpus/res-header.log', BUNYAN, __dirname), | ||
function (err, stdout, stderr) { | ||
t.ifError(err); | ||
t.equal(stdout, expect); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
test('res without "header"', function (t) { | ||
var expect = [ | ||
/* BEGIN JSSTYLED */ | ||
'[2017-08-02T22:37:34.798Z] INFO: res-header/76488 on danger0.local: response sent', | ||
' HTTP/1.1 200 OK' | ||
/* END JSSTYLED */ | ||
].join('\n') + '\n'; | ||
exec(_('%s %s/corpus/res-without-header.log', BUNYAN, __dirname), | ||
function (err, stdout, stderr) { | ||
t.ifError(err); | ||
t.equal(stdout, expect); | ||
t.end(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"res-header","hostname":"danger0.local","pid":76488,"level":30,"res":{"statusCode":200,"header":"HTTP/1.1 200 OK\r\nFoo: bar\r\nDate: Wed, 02 Aug 2017 22:37:34 GMT\r\nConnection: keep-alive\r\nContent-Length: 21\r\n\r\n"},"msg":"response sent","time":"2017-08-02T22:37:34.798Z","v":0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"res-header","hostname":"danger0.local","pid":76488,"level":30,"res":{"statusCode":200},"msg":"response sent","time":"2017-08-02T22:37:34.798Z","v":0} |