diff --git a/functions/helloworld/index.js b/functions/helloworld/index.js index ab2851492c..270cbd1fd1 100644 --- a/functions/helloworld/index.js +++ b/functions/helloworld/index.js @@ -108,7 +108,7 @@ exports.helloGCS = (event, callback) => { exports.helloGCSGeneric = (event, callback) => { const file = event.data; - console.log(` Event ${event.eventId}`); + console.log(` Event: ${event.eventId}`); console.log(` Event Type: ${event.eventType}`); console.log(` Bucket: ${file.bucket}`); console.log(` File: ${file.name}`); diff --git a/functions/helloworld/test/sample.unit.http.test.js b/functions/helloworld/test/sample.unit.http.test.js index e08d1d6ec8..b495c3ca68 100644 --- a/functions/helloworld/test/sample.unit.http.test.js +++ b/functions/helloworld/test/sample.unit.http.test.js @@ -21,7 +21,7 @@ const uuid = require(`uuid`); const helloHttp = require(`..`).helloHttp; test(`helloHttp: should print a name`, t => { - // Initialize mocks + // Mock ExpressJS 'req' and 'res' parameters const name = uuid.v4(); const req = { body: { @@ -39,7 +39,7 @@ test(`helloHttp: should print a name`, t => { }); test(`helloHttp: should print hello world`, t => { - // Initialize mocks + // Mock ExpressJS 'req' and 'res' parameters const req = { body: {} }; diff --git a/functions/log/index.js b/functions/log/index.js index 62e51cbe54..809de6d0b0 100644 --- a/functions/log/index.js +++ b/functions/log/index.js @@ -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] diff --git a/functions/log/test/index.test.js b/functions/log/test/index.test.js index 8c6184c26e..fc9ff46c7b 100644 --- a/functions/log/test/index.test.js +++ b/functions/log/test/index.test.js @@ -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) => {