Skip to content

Commit

Permalink
Delete unused functions samples (#1334)
Browse files Browse the repository at this point in the history
* Delete unused functions samples
  • Loading branch information
fhinkel authored Jun 10, 2019
1 parent 6dee350 commit ded1994
Show file tree
Hide file tree
Showing 37 changed files with 36 additions and 481 deletions.
13 changes: 0 additions & 13 deletions .kokoro/functions/errorreporting.cfg

This file was deleted.

20 changes: 0 additions & 20 deletions functions/background/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,6 @@

'use strict';

// [START functions_background_helloworld]
/**
* Background Cloud Function.
*
* @param {object} event The Cloud Functions event.
* @param {object} event.data The event data.
* @param {function} callback The callback function.
*/
exports.helloWorld = (event, callback) => {
if (!event.data.myMessage) {
// This is an error case, "myMessage" is required
callback(new Error('No message defined!'));
} else {
// Everything is ok
console.log(event.data.myMessage);
callback();
}
};
// [END functions_background_helloworld]

// [START functions_background_promise]
const requestPromiseNative = require('request-promise-native');

Expand Down
27 changes: 0 additions & 27 deletions functions/background/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,6 @@ function getSample() {
beforeEach(tools.stubConsole);
afterEach(tools.restoreConsole);

it('should echo message', () => {
const event = {
data: {
myMessage: 'hi',
},
};
const sample = getSample();
const callback = sinon.stub();

sample.program.helloWorld(event, callback);

assert.strictEqual(console.log.callCount, 1);
assert.deepStrictEqual(console.log.firstCall.args, [event.data.myMessage]);
assert.strictEqual(callback.callCount, 1);
assert.deepStrictEqual(callback.firstCall.args, []);
});

it('should say no message was provided', () => {
const error = new Error('No message defined!');
const callback = sinon.stub();
const sample = getSample();
sample.program.helloWorld({data: {}}, callback);

assert.strictEqual(callback.callCount, 1);
assert.deepStrictEqual(callback.firstCall.args, [error]);
});

it('should make a promise request', () => {
const sample = getSample();
const event = {
Expand Down
22 changes: 0 additions & 22 deletions functions/concepts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,6 @@ exports.errorTypes = (req, res) => {
}
// [END functions_concepts_error_object]

const someCondition = !!req.body.throwAsString;

/* eslint-disable no-throw-literal */
// [START functions_concepts_error_unknown]
try {
// Throw an unknown error type
if (someCondition) {
throw 'Error string!';
} else {
throw new Error('Error object!');
}
} catch (err) {
// Determine the error type
if (err instanceof Error) {
console.error(err);
} else {
console.error(new Error(err));
}
}
// [END functions_concepts_error_unknown]
/* eslint-enable no-throw-literal */

res.end();
};

Expand Down
9 changes: 0 additions & 9 deletions functions/concepts/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,10 @@ afterEach(tools.restoreConsole);

it('should demonstrate error type behavior', () => {
const objError = new Error('Error object!');
const strError = new Error('Error string!');

const req = {body: {throwAsString: true}};
const res = {end: sinon.stub()};

// Test throwing both objects and strings
sample.errorTypes(req, res);
assert.deepStrictEqual(console.error.getCall(0).args, [objError]);
assert.deepStrictEqual(console.error.getCall(1).args, [strError]);

// Test throwing objects only
req.body.throwAsString = false;
sample.errorTypes(req, res);
assert.deepStrictEqual(console.error.getCall(2).args, [objError]);
assert.deepStrictEqual(console.error.getCall(3).args, [objError]);
});
3 changes: 0 additions & 3 deletions functions/errorreporting/.eslintrc.yml

This file was deleted.

27 changes: 0 additions & 27 deletions functions/errorreporting/README.md

This file was deleted.

149 changes: 0 additions & 149 deletions functions/errorreporting/index.js

This file was deleted.

11 changes: 0 additions & 11 deletions functions/errorreporting/package.json

This file was deleted.

Loading

0 comments on commit ded1994

Please sign in to comment.