Skip to content

Commit 792a62a

Browse files
authored
fix: making unique region tags for helloerror samples for functions (#3030)
* fix: making unique region tags for helloerror samples for functions * refactor: separating tests * chore: lint fix * chore: rename region tag
1 parent 3353992 commit 792a62a

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

functions/helloworld/helloError/index.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ exports.helloError = (event, context, callback) => {
3030
// [START functions_helloworld_error]
3131
// These WILL be reported to Error Reporting
3232
throw new Error('I failed you'); // Will cause a cold start if not caught
33-
3433
// [END functions_helloworld_error]
3534
};
3635

@@ -42,12 +41,12 @@ exports.helloError = (event, context, callback) => {
4241
* @param {function} callback The callback function.
4342
*/
4443
exports.helloError2 = (event, context, callback) => {
45-
// [START functions_helloworld_error]
44+
// [START functions_helloworld_error_2]
4645
// These WILL be reported to Error Reporting
4746
console.error(new Error('I failed you')); // Logging an Error object
4847
console.error('I failed you'); // Logging something other than an Error object
4948
throw 1; // Throwing something other than an Error object
50-
// [END functions_helloworld_error]
49+
// [END functions_helloworld_error_2]
5150
};
5251

5352
/**
@@ -58,16 +57,16 @@ exports.helloError2 = (event, context, callback) => {
5857
* @param {function} callback The callback function.
5958
*/
6059
exports.helloError3 = (event, context, callback) => {
60+
// [START functions_helloworld_error_3]
6161
// This will NOT be reported to Error Reporting
62-
// [START functions_helloworld_error]
6362
callback('I failed you');
64-
// [END functions_helloworld_error]
63+
// [END functions_helloworld_error_3]
6564
};
6665

6766
// HTTP Cloud Function that returns an error.
6867
functions.http('helloError4', (req, res) => {
68+
// [START functions_helloworld_error_4]
6969
// This will NOT be reported to Error Reporting
70-
// [START functions_helloworld_error]
7170
res.status(500).send('I failed you');
72-
// [END functions_helloworld_error]
71+
// [END functions_helloworld_error_4]
7372
});

functions/helloworld/helloError/test/index.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@ describe('index.test.js', () => {
2323
it('helloError: should throw an error', () => {
2424
assert.throws(program.helloError, 'Error: I failed you');
2525
});
26+
});
27+
});
2628

29+
describe('functions_helloworld_error_2', () => {
30+
describe('Error handling (unit tests)', () => {
2731
it('helloError2: should throw a value', () => {
2832
assert.throws(program.helloError2, '1');
2933
});
34+
});
35+
});
3036

37+
describe('functions_helloworld_error_3', () => {
38+
describe('Error handling (unit tests)', () => {
3139
it('helloError3: callback should return an errback value', () => {
3240
const cb = sinon.stub();
3341
program.helloError3(null, null, cb);

0 commit comments

Comments
 (0)