mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
switch to data
This commit is contained in:
parent
76fef37122
commit
eccbca327e
@ -27,7 +27,7 @@ const transformMessages = parsedMsg => {
|
||||
if (event.headers) {
|
||||
const text = `Received http event on path ${parsedMsg.path} ${parsedMsg.method}\n`;
|
||||
// TODO const ppBody = prettifyValue(event.body);
|
||||
const ppBody = prettifyValue(event.data);
|
||||
const ppBody = prettifyValue(event.body);
|
||||
const bodyText = ` ${caret} body:\n${ppBody}`;
|
||||
return `${text}${bodyText}\n`;
|
||||
}
|
||||
|
||||
@ -32,4 +32,22 @@ describe('logEventGateway', () => {
|
||||
const expected = '\u001b[38;5;173m Event Gateway | \u001b[39mRegistered function s1-f1\n';
|
||||
expect(logStub.getCall(0).args[0]).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('format and log event received', () => {
|
||||
logEventGateway(
|
||||
JSON.stringify({
|
||||
level: 'debug',
|
||||
ts: 1502464166.8101041,
|
||||
msg: 'Event received.',
|
||||
event:
|
||||
'{"headers":{"Accept":["image/webp,image/apng,image/*,*/*;q=0.8"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["en-US,en;q=0.8"],"Cache-Control":["no-cache"],"Connection":["keep-alive"],"Pragma":["no-cache"],"Referer":["http://localhost:4000/"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"]},"query":{},"body":""}',
|
||||
path: '/favicon.ico',
|
||||
method: 'GET',
|
||||
})
|
||||
);
|
||||
expect(logStub.calledOnce).to.be.equal(true);
|
||||
const expected = // eslint-disable-next-line max-len
|
||||
'\u001b[38;5;173m Event Gateway | \u001b[39mReceived http event on path /favicon.ico GET\n \u001b[38;5;173m|\u001b[39m body:\n \u001b[38;5;173m|\u001b[39m ""\n';
|
||||
expect(logStub.getCall(0).args[0]).to.be.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user