-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions #245
Conversation
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
@ace-n @jasonpolites PTAL |
@jmdobry Missing module is causing CircleCI tests to fail - mind fixing that?
|
Will do |
6478988
to
02e99ac
Compare
CLAs look good, thanks! |
Current coverage is 92.06% (diff: 98.49%)@@ master #245 diff @@
==========================================
Files 66 66
Lines 2639 2634 -5
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 2434 2425 -9
- Misses 205 209 +4
Partials 0 0
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(These are comments from looking at the code - I'll run through the tutorials now and post my feedback here once I'm done.)
} | ||
describe(`functions:datastore`, () => { | ||
it(`set: Set fails without a value`, () => { | ||
const expectedMsg = `Value not provided. Make sure you have a "value" property in your request`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meta-question/nit: some tests store expected results in their own variables, while others put the constants directly in the assert call. Is this something we should standardize, or am I being pedantic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the general pattern I follow is to pull the expected value into a variable when the line is getting long.
*/ | ||
exports.helloBackgroundError = function helloBackgroundError (context, data) { | ||
exports.helloBackgroundError = function helloBackgroundError (event, callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be made into an arrow function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is supposed to be there, indicating that the user would put their own code there.
// All is good, respond with a message | ||
return context.success('Hello World!'); | ||
|
||
// Do something |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this comment, unless there's something missing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is supposed to be there, indicating that the user would put their own code there.
throw new Error('Bucket not provided. Make sure you have a ' + | ||
'"bucket" property in your request'); | ||
// [START functions_word_count_stream] | ||
function getFileStream (file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we clarify that file
is an object or use a different name? (e.g. fileObj
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll delete the region tag, as it's not shown in the docs.
return fs.createReadStream(filepath, { encoding: 'utf8' }); | ||
} | ||
const file = { | ||
createReadStream: () => fs.createReadStream(path.join(__dirname, `../${filename}`), { encoding: `utf8` }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we split this into more than 1 line? e.g:
createReadStream: () =>
fs.createReadStream(
path.join(...),
{ encoding: 'utf8' }
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
assert.deepEqual(sample.mocks.res.status.callCount, 1); | ||
assert.deepEqual(sample.mocks.res.status.firstCall.args, [500]); | ||
assert.deepEqual(sample.mocks.res.send.callCount, 1); | ||
assert.deepEqual(sample.mocks.res.send.firstCall.args[0].message, expectedMsg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: why deepEqual
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
assert.deepEqual(sample.mocks.res.status.callCount, 1); | ||
assert.deepEqual(sample.mocks.res.status.firstCall.args, [500]); | ||
assert.deepEqual(sample.mocks.res.send.callCount, 1); | ||
assert.deepEqual(sample.mocks.res.send.firstCall.args[0].message, expectedMsg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: why deepEqual
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
*/ | ||
function getPayload (requestBody) { | ||
if (!requestBody.to) { | ||
var error = new Error('To email address not provided. Make sure you have a ' + | ||
'"to" property in your request'); | ||
const error = new Error('To email address not provided. Make sure you have a "to" property in your request'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits:
- Repetition? (Helper function?)
- What's the purpose of using a "const" here, given that you're only using it once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- too much abstraction
- I have to first save the error to a variable so I can add the
code
property to it.
throw new Error('Filename not provided. Make sure you have a ' + | ||
'"name" property in your request'); | ||
} | ||
exports.sendgridLoad = function sendgridLoad (event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These docstrings and parameters don't match up. 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
// Extract the first entity from the result list, if any | ||
if (response && response.itemListElement && | ||
response.itemListElement.length) { | ||
if (response && response.itemListElement && response.itemListElement.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe clarify the .length
part? (e.g. .length > 0
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
1930ef8
to
a63abfb
Compare
* @returns {Promise} | ||
*/ | ||
exports.helloPromise = function helloPromise (data) { | ||
exports.helloPromise = function helloPromise (event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the function names here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes for better stack traces.
|
||
* Replace `[YOUR_BUCKET_NAME]` with the name of your Cloud Storage Bucket. | ||
* Replace `YOUR_BUCKET_NAME` with the name of your Cloud Storage Bucket. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be repeated every time, or can we just have a blanket notice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Fixed some stuff related to the OCR sample. |
* updated CHANGELOG.md * updated package.json * updated samples/package.json
* updated CHANGELOG.md * updated package.json * updated samples/package.json
* chore(main): release 3.0.2 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* chore(main): release 3.0.2 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* chore(main): release 3.0.2 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
🤖 I have created a release \*beep\* \*boop\* --- ### [3.0.1](https://www.github.com/googleapis/nodejs-document-ai/compare/v3.0.0...v3.0.1) (2021-07-21) ### Bug Fixes * **deps:** google-gax v2.17.1 ([#243](https://www.github.com/googleapis/nodejs-document-ai/issues/243)) ([a9e4efd](https://www.github.com/googleapis/nodejs-document-ai/commit/a9e4efd2478def845376a951c40b76e3384a8b29)) * Updating WORKSPACE files to use the newest version of the Typescript generator. ([#245](https://www.github.com/googleapis/nodejs-document-ai/issues/245)) ([06bf319](https://www.github.com/googleapis/nodejs-document-ai/commit/06bf3190cad3c9ce98e13aff718bb11db85dd4e5)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release \*beep\* \*boop\* --- ### [3.0.1](https://www.github.com/googleapis/nodejs-document-ai/compare/v3.0.0...v3.0.1) (2021-07-21) ### Bug Fixes * **deps:** google-gax v2.17.1 ([#243](https://www.github.com/googleapis/nodejs-document-ai/issues/243)) ([a9e4efd](https://www.github.com/googleapis/nodejs-document-ai/commit/a9e4efd2478def845376a951c40b76e3384a8b29)) * Updating WORKSPACE files to use the newest version of the Typescript generator. ([#245](https://www.github.com/googleapis/nodejs-document-ai/issues/245)) ([06bf319](https://www.github.com/googleapis/nodejs-document-ai/commit/06bf3190cad3c9ce98e13aff718bb11db85dd4e5)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release \*beep\* \*boop\* --- ### [3.0.1](https://www.github.com/googleapis/nodejs-document-ai/compare/v3.0.0...v3.0.1) (2021-07-21) ### Bug Fixes * **deps:** google-gax v2.17.1 ([#243](https://www.github.com/googleapis/nodejs-document-ai/issues/243)) ([a9e4efd](https://www.github.com/googleapis/nodejs-document-ai/commit/a9e4efd2478def845376a951c40b76e3384a8b29)) * Updating WORKSPACE files to use the newest version of the Typescript generator. ([#245](https://www.github.com/googleapis/nodejs-document-ai/issues/245)) ([06bf319](https://www.github.com/googleapis/nodejs-document-ai/commit/06bf3190cad3c9ce98e13aff718bb11db85dd4e5)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release \*beep\* \*boop\* --- ### [3.0.1](https://www.github.com/googleapis/nodejs-document-ai/compare/v3.0.0...v3.0.1) (2021-07-21) ### Bug Fixes * **deps:** google-gax v2.17.1 ([#243](https://www.github.com/googleapis/nodejs-document-ai/issues/243)) ([a9e4efd](https://www.github.com/googleapis/nodejs-document-ai/commit/a9e4efd2478def845376a951c40b76e3384a8b29)) * Updating WORKSPACE files to use the newest version of the Typescript generator. ([#245](https://www.github.com/googleapis/nodejs-document-ai/issues/245)) ([06bf319](https://www.github.com/googleapis/nodejs-document-ai/commit/06bf3190cad3c9ce98e13aff718bb11db85dd4e5)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release \*beep\* \*boop\* --- ## [2.3.0](https://www.github.com/googleapis/nodejs-datacatalog/compare/v2.2.0...v2.3.0) (2021-04-27) ### Features * new RenameTagTemplateFieldEnumValue API ([#244](https://www.github.com/googleapis/nodejs-datacatalog/issues/244)) ([1efaf9b](https://www.github.com/googleapis/nodejs-datacatalog/commit/1efaf9be12b84135643761cf01372726ec7dd249)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release \*beep\* \*boop\* --- ## [2.3.0](https://www.github.com/googleapis/nodejs-datacatalog/compare/v2.2.0...v2.3.0) (2021-04-27) ### Features * new RenameTagTemplateFieldEnumValue API ([#244](https://www.github.com/googleapis/nodejs-datacatalog/issues/244)) ([1efaf9b](https://www.github.com/googleapis/nodejs-datacatalog/commit/1efaf9be12b84135643761cf01372726ec7dd249)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
No description provided.