Skip to content

Commit 1453f75

Browse files
author
Ace Nassri
authored
Make logging sample an HTTP function (#691)
* 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
1 parent 29f1230 commit 1453f75

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

functions/log/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
'use strict';
1717

1818
// [START functions_log_helloworld]
19-
exports.helloWorld = (event, callback) => {
19+
exports.helloWorld = (req, res) => {
2020
console.log('I am a log entry!');
2121
console.error('I am an error!');
22-
callback();
22+
res.end();
2323
};
2424
// [END functions_log_helloworld]
2525

functions/log/test/index.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ test.afterEach.always(tools.restoreConsole);
5757

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

62-
getSample().program.helloWorld({}, callback);
62+
getSample().program.helloWorld({}, res);
6363

6464
t.is(console.log.callCount, 1);
6565
t.deepEqual(console.log.firstCall.args, [expectedMsg]);
66-
t.is(callback.callCount, 1);
67-
t.deepEqual(callback.firstCall.args, []);
66+
t.is(res.end.callCount, 1);
67+
t.deepEqual(res.end.firstCall.args, []);
6868
});
6969

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

0 commit comments

Comments
 (0)