Skip to content

Commit b5d0e1f

Browse files
author
Ace Nassri
committed
Change parameter name (#715)
1 parent 3394dee commit b5d0e1f

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

functions/http/index.js

-20
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

-26
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,6 @@ function getMocks () {
6868
test.beforeEach(tools.stubConsole);
6969
test.afterEach.always(tools.restoreConsole);
7070

71-
test.serial(`http:helloworld: should error with no message`, (t) => {
72-
const mocks = getMocks();
73-
const httpSample = getSample();
74-
mocks.req.body = {};
75-
httpSample.sample.helloWorld(mocks.req, mocks.res);
76-
77-
t.true(mocks.res.status.calledOnce);
78-
t.is(mocks.res.status.firstCall.args[0], 400);
79-
t.true(mocks.res.send.calledOnce);
80-
t.is(mocks.res.send.firstCall.args[0], `No message defined!`);
81-
});
82-
83-
test.serial(`http:helloworld: should log message`, (t) => {
84-
const mocks = getMocks();
85-
const httpSample = getSample();
86-
mocks.req.body = {
87-
message: `hi`
88-
};
89-
httpSample.sample.helloWorld(mocks.req, mocks.res);
90-
91-
t.true(mocks.res.status.calledOnce);
92-
t.is(mocks.res.status.firstCall.args[0], 200);
93-
t.true(mocks.res.end.calledOnce);
94-
t.true(console.log.calledWith(`hi`));
95-
});
96-
9771
test.serial(`http:helloHttp: should handle GET`, (t) => {
9872
const mocks = getMocks();
9973
const httpSample = getSample();

0 commit comments

Comments
 (0)