Skip to content
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

Merged
merged 1 commit into from Nov 16, 2016
Merged

Functions #245

merged 1 commit into from Nov 16, 2016

Conversation

jmdobry
Copy link
Member

@jmdobry jmdobry commented Oct 26, 2016

No description provided.

@googlebot
Copy link

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.

@jmdobry
Copy link
Member Author

jmdobry commented Nov 1, 2016

@ace-n @jasonpolites PTAL

@ace-n
Copy link
Contributor

ace-n commented Nov 2, 2016

@jmdobry Missing module is causing CircleCI tests to fail - mind fixing that?

/home/ubuntu/nodejs-docs-samples/bigquery/node_modules/grpc/src/node/extension_binary/grpc_node.node

@jmdobry
Copy link
Member Author

jmdobry commented Nov 3, 2016

Will do

@jmdobry jmdobry force-pushed the functions branch 2 times, most recently from 6478988 to 02e99ac Compare November 5, 2016 21:34
@googlebot
Copy link

CLAs look good, thanks!

@codecov-io
Copy link

Current coverage is 92.06% (diff: 98.49%)

Merging #245 into master will decrease coverage by 0.16%

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

Powered by Codecov. Last update 2cf8055...8cb8f04

Copy link
Contributor

@ace-n ace-n left a 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`;
Copy link
Contributor

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?

Copy link
Member Author

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) {
Copy link
Contributor

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?

Copy link
Member Author

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
Copy link
Contributor

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?

Copy link
Member Author

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) {
Copy link
Contributor

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)

Copy link
Member Author

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` })
Copy link
Contributor

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' }
    )

Copy link
Member Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: why deepEqual?

Copy link
Member Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: why deepEqual?

Copy link
Member Author

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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits:

  1. Repetition? (Helper function?)
  2. What's the purpose of using a "const" here, given that you're only using it once?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. too much abstraction
  2. 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) {
Copy link
Contributor

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. 😕

Copy link
Member Author

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) {
Copy link
Contributor

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?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jmdobry jmdobry force-pushed the functions branch 2 times, most recently from 1930ef8 to a63abfb Compare November 14, 2016 20:45
* @returns {Promise}
*/
exports.helloPromise = function helloPromise (data) {
exports.helloPromise = function helloPromise (event) {
Copy link
Contributor

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?

Copy link
Member Author

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.
Copy link
Contributor

@ace-n ace-n Nov 15, 2016

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jmdobry
Copy link
Member Author

jmdobry commented Nov 16, 2016

Fixed some stuff related to the OCR sample.

@jmdobry jmdobry merged commit 3c77013 into master Nov 16, 2016
grayside pushed a commit that referenced this pull request Oct 26, 2022
* updated CHANGELOG.md

* updated package.json

* updated samples/package.json
grayside pushed a commit that referenced this pull request Nov 3, 2022
* updated CHANGELOG.md

* updated package.json

* updated samples/package.json
kweinmeister pushed a commit that referenced this pull request Nov 7, 2022
* 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>
ahrarmonsur pushed a commit that referenced this pull request Nov 8, 2022
kweinmeister pushed a commit that referenced this pull request Nov 8, 2022
* 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>
kweinmeister pushed a commit that referenced this pull request Nov 8, 2022
* 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>
ace-n pushed a commit that referenced this pull request Nov 10, 2022
NimJay pushed a commit that referenced this pull request Nov 11, 2022
ace-n pushed a commit that referenced this pull request Nov 11, 2022
ace-n pushed a commit that referenced this pull request Nov 11, 2022
ace-n pushed a commit that referenced this pull request Nov 11, 2022
ace-n pushed a commit that referenced this pull request Nov 12, 2022
ace-n pushed a commit that referenced this pull request Nov 14, 2022
telpirion pushed a commit that referenced this pull request Nov 16, 2022
NimJay pushed a commit that referenced this pull request Nov 18, 2022
NimJay pushed a commit that referenced this pull request Nov 18, 2022
NimJay pushed a commit that referenced this pull request Nov 19, 2022
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
NimJay pushed a commit that referenced this pull request Nov 19, 2022
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants