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

Simplify BigQuery samples according to our standard. #207

Merged
merged 4 commits into from
Sep 7, 2016
Merged

Conversation

jmdobry
Copy link
Member

@jmdobry jmdobry commented Sep 6, 2016

No description provided.

@jmdobry
Copy link
Member Author

jmdobry commented Sep 7, 2016

Same eslint const issue is plaguing this PR.

@@ -49,15 +52,16 @@ describe('bigquery:datasets', function () {
describe('listDatasets', function () {
it('should list datasets', function (done) {
program.listDatasets(projectId, function (err, datasets) {
assert.ifError(err);
assert.equal(err, null);
assert(Array.isArray(datasets));
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix assert style?

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.

format: options.format,
gzip: options.gzip
};
var Storage = require('@google-cloud/storage');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason you're declaring this here and on line 170?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because this is an import. Imports should be as close to top-level statements as possible. In ES6, the new version of JavaScript, this is enforced by the new import syntax, which only works as a top-level statement.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, good to know.

assert.equal(example.mocks.job.getMetadata.calledOnce, true);
assert.deepEqual(example.mocks.job.getMetadata.firstCall.args.slice(0, -1), []);
assert.equal(example.mocks.job.on.calledTwice, true);
assert.deepEqual(example.mocks.job.on.firstCall.args.slice(0, -1), ['error']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these tests depend on the order of the callbacks? (It seems like they do, at least currently...)

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 sample is deterministic and the current assertions are about as restrictive/specific as it gets, and won't fail unless someone changes the sample. The only alternative would be looser assertions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough - adding this feature would likely add arguably unnecessary complexity to the tests.

assert.deepEqual(program.copyTable.firstCall.args.slice(0, -1),
[srcDataset, srcTable, destDataset, destTable]
);
assert.deepEqual(program.copyTable.firstCall.args.slice(0, -1), [srcDatasetId, srcTableId, destDatasetId, destTableId]);
Copy link
Contributor

@ace-n ace-n Sep 7, 2016

Choose a reason for hiding this comment

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

Nit: not personally a fan of lines > 100 chars.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps in a separate PR we can consider switching from Semistandard to ESLint + JSCS to give us some configurability and better enforceability on our style?

@ace-n
Copy link
Contributor

ace-n commented Sep 7, 2016

LGTM, but I think there's some App Engine dependency issue going on...

@jmdobry jmdobry merged commit b5f33bf into master Sep 7, 2016
@jmdobry jmdobry deleted the simplify branch September 7, 2016 22:34
kweinmeister pushed a commit that referenced this pull request Nov 18, 2022
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.

2 participants