Skip to content

Commit

Permalink
Make logging sample an HTTP function (#691)
Browse files Browse the repository at this point in the history
* Update index.js

* Clarify mocking comments (#682)

* fix: just adding : for log consistency (#694)

* Update index.js

* Update index.js

* Update index.js

* Fix test
  • Loading branch information
Ace Nassri authored Jul 23, 2018
1 parent 29f1230 commit 1453f75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions functions/log/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
'use strict';

// [START functions_log_helloworld]
exports.helloWorld = (event, callback) => {
exports.helloWorld = (req, res) => {
console.log('I am a log entry!');
console.error('I am an error!');
callback();
res.end();
};
// [END functions_log_helloworld]

Expand Down
8 changes: 4 additions & 4 deletions functions/log/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ test.afterEach.always(tools.restoreConsole);

test.serial(`should write to log`, (t) => {
const expectedMsg = `I am a log entry!`;
const callback = sinon.stub();
const res = { end: sinon.stub() };

getSample().program.helloWorld({}, callback);
getSample().program.helloWorld({}, res);

t.is(console.log.callCount, 1);
t.deepEqual(console.log.firstCall.args, [expectedMsg]);
t.is(callback.callCount, 1);
t.deepEqual(callback.firstCall.args, []);
t.is(res.end.callCount, 1);
t.deepEqual(res.end.firstCall.args, []);
});

test.serial(`getLogEntries: should retrieve logs`, (t) => {
Expand Down

0 comments on commit 1453f75

Please sign in to comment.