diff --git a/functions/http/index.js b/functions/http/index.js index 090f871116..bab3df85b5 100644 --- a/functions/http/index.js +++ b/functions/http/index.js @@ -15,26 +15,6 @@ 'use strict'; -// [START functions_http_helloworld] -/** - * Responds to any HTTP request that can provide a "message" field in the body. - * - * @param {Object} req ExpressJS object containing the received HTTP request. - * @param {Object} res ExpressJS object containing the HTTP response to send. - */ -exports.helloWorld = (req, res) => { - if (req.body.message === undefined) { - // This is an error case, as "message" is required - res.status(400).send('No message defined!'); - } else { - // Everything is ok - call request-terminating method to signal function - // completion. (Otherwise, the function may continue to run until timeout.) - console.log(req.body.message); - res.status(200).end(); - } -}; -// [END functions_http_helloworld] - // [START functions_http_content] /** * Responds to an HTTP request using data from the request body parsed according diff --git a/functions/http/test/index.test.js b/functions/http/test/index.test.js index b80fab2c94..263d85ac2a 100644 --- a/functions/http/test/index.test.js +++ b/functions/http/test/index.test.js @@ -57,32 +57,6 @@ function getMocks () { test.beforeEach(tools.stubConsole); test.afterEach.always(tools.restoreConsole); -test.serial(`http:helloworld: should error with no message`, (t) => { - const mocks = getMocks(); - const httpSample = getSample(); - mocks.req.body = {}; - httpSample.sample.helloWorld(mocks.req, mocks.res); - - t.true(mocks.res.status.calledOnce); - t.is(mocks.res.status.firstCall.args[0], 400); - t.true(mocks.res.send.calledOnce); - t.is(mocks.res.send.firstCall.args[0], `No message defined!`); -}); - -test.serial(`http:helloworld: should log message`, (t) => { - const mocks = getMocks(); - const httpSample = getSample(); - mocks.req.body = { - message: `hi` - }; - httpSample.sample.helloWorld(mocks.req, mocks.res); - - t.true(mocks.res.status.calledOnce); - t.is(mocks.res.status.firstCall.args[0], 200); - t.true(mocks.res.end.calledOnce); - t.true(console.log.calledWith(`hi`)); -}); - test.serial(`http:helloHttp: should handle GET`, (t) => { const mocks = getMocks(); const httpSample = getSample();