Skip to content

Commit ce721d6

Browse files
author
Ace Nassri
authored
Change parameter name (#715)
1 parent 19ec919 commit ce721d6

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

functions/http/index.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,6 @@
1515

1616
'use strict';
1717

18-
// [START functions_http_helloworld]
19-
/**
20-
* Responds to any HTTP request that can provide a "message" field in the body.
21-
*
22-
* @param {Object} req ExpressJS object containing the received HTTP request.
23-
* @param {Object} res ExpressJS object containing the HTTP response to send.
24-
*/
25-
exports.helloWorld = (req, res) => {
26-
if (req.body.message === undefined) {
27-
// This is an error case, as "message" is required
28-
res.status(400).send('No message defined!');
29-
} else {
30-
// Everything is ok - call request-terminating method to signal function
31-
// completion. (Otherwise, the function may continue to run until timeout.)
32-
console.log(req.body.message);
33-
res.status(200).end();
34-
}
35-
};
36-
// [END functions_http_helloworld]
37-
3818
// [START functions_http_content]
3919
/**
4020
* Responds to an HTTP request using data from the request body parsed according

functions/http/test/index.test.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,6 @@ function getMocks () {
5757
test.beforeEach(tools.stubConsole);
5858
test.afterEach.always(tools.restoreConsole);
5959

60-
test.serial(`http:helloworld: should error with no message`, (t) => {
61-
const mocks = getMocks();
62-
const httpSample = getSample();
63-
mocks.req.body = {};
64-
httpSample.sample.helloWorld(mocks.req, mocks.res);
65-
66-
t.true(mocks.res.status.calledOnce);
67-
t.is(mocks.res.status.firstCall.args[0], 400);
68-
t.true(mocks.res.send.calledOnce);
69-
t.is(mocks.res.send.firstCall.args[0], `No message defined!`);
70-
});
71-
72-
test.serial(`http:helloworld: should log message`, (t) => {
73-
const mocks = getMocks();
74-
const httpSample = getSample();
75-
mocks.req.body = {
76-
message: `hi`
77-
};
78-
httpSample.sample.helloWorld(mocks.req, mocks.res);
79-
80-
t.true(mocks.res.status.calledOnce);
81-
t.is(mocks.res.status.firstCall.args[0], 200);
82-
t.true(mocks.res.end.calledOnce);
83-
t.true(console.log.calledWith(`hi`));
84-
});
85-
8660
test.serial(`http:helloHttp: should handle GET`, (t) => {
8761
const mocks = getMocks();
8862
const httpSample = getSample();

0 commit comments

Comments
 (0)