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

Bring test coverage to 100% #870

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/bigquery/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Dataset.prototype.delete = function(options, callback) {
*
* @param {function} callback - The callback function.
* @param {?error} callback.err - An error returned while making this request
* @param {object} callback.metadata - The Dataset metadata
* @param {object} callback.metadata - The dataset's metadata.
* @param {object} callback.apiResponse - The full API response.
*
* @example
Expand Down Expand Up @@ -284,28 +284,27 @@ Dataset.prototype.query = function(options, callback) {
* @param {object} metadata - Metadata to save on the Dataset.
* @param {function} callback - The callback function.
* @param {?error} callback.err - An error returned while making this request
* @param {object} callback.metadata - The metadata of the Dataset object.
* @param {object} callback.apiResponse - The full API response.
* @param {object} callback.apiResponse - The full API response.
*
* @example
* var metadata = {
* description: 'Information for every institution in the 2013 IPEDS universe'
* };
*
* dataset.setMetadata(metadata, function(err, metadata, apiResponse) {});
* dataset.setMetadata(metadata, function(err, apiResponse) {});

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

*/
Dataset.prototype.setMetadata = function(metadata, callback) {
var that = this;

this.makeReq_('PATCH', '', null, metadata, function(err, resp) {
if (err) {
callback(err, null, resp);
callback(err, resp);
return;
}

that.metadata = resp;

callback(null, that.metadata, resp);
callback(null, resp);
});
};

Expand Down
11 changes: 5 additions & 6 deletions lib/bigquery/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,9 @@ Table.prototype.getRows = function(options, callback) {

if (resp.rows && resp.rows.length > 0 && !that.metadata.schema) {
// We don't know the schema for this table yet. Do a quick stat.
that.getMetadata(function(err) {
that.getMetadata(function(err, metadata, apiResponse) {
if (err) {
onComplete(err);
onComplete(err, null, null, apiResponse);
return;
}

Expand Down Expand Up @@ -867,8 +867,7 @@ Table.prototype.query = function(query, callback) {
* a [Table resource](http://goo.gl/sl8Dmg) for more detailed information.
* @param {function} callback - The callback function.
* @param {?error} callback.err - An error returned while making this request.
* @param {object} callback.metadata - The metadata of the Table.
* @param {object} callback.apiResponse - The full API response.
* @param {object} callback.apiResponse - The full API response.
*
* @example
* var metadata = {
Expand All @@ -892,13 +891,13 @@ Table.prototype.setMetadata = function(metadata, callback) {

this.makeReq_('PUT', '', null, metadata, function(err, resp) {
if (err) {
callback(err, null, resp);
callback(err, resp);
return;
}

that.metadata = resp;

callback(null, that.metadata, resp);
callback(null, resp);
});
};

Expand Down
2 changes: 1 addition & 1 deletion lib/compute/firewall.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Firewall.prototype.delete = function(callback) {
*
* @param {function=} callback - The callback function.
* @param {?error} callback.err - An error returned while making this request
* @param {object} callback.metadata - The network's metadata.
* @param {object} callback.metadata - The firewall's metadata.
* @param {object} callback.apiResponse - The full API response.
*
* @example
Expand Down
2 changes: 1 addition & 1 deletion lib/compute/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Snapshot.prototype.delete = function(callback) {
*
* @param {function=} callback - The callback function.
* @param {?error} callback.err - An error returned while making this request
* @param {object} callback.metadata - The zone's metadata.
* @param {object} callback.metadata - The snapshot's metadata.
* @param {object} callback.apiResponse - The full API response.
*
* @example
Expand Down
6 changes: 3 additions & 3 deletions lib/datastore/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,14 @@ Dataset.prototype.createQuery = function(namespace, kind) {
*
* done();
* });
* }, function(err) {});
* }, function(err, apiResponse) {});
*/
Dataset.prototype.runInTransaction = function(fn, callback) {
var newTransaction = this.createTransaction_();

newTransaction.begin_(function(err) {
newTransaction.begin_(function(err, resp) {
if (err) {
callback(err);
callback(err, resp);
return;
}

Expand Down
11 changes: 0 additions & 11 deletions lib/datastore/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,4 @@ Transaction.prototype.save = function(entities) {
});
};

/**
* mapQuery
*
* @todo Implement.
*
* @private
*/
Transaction.prototype.mapQuery = function() {
throw new Error('not yet implemented');
};

module.exports = Transaction;
4 changes: 2 additions & 2 deletions lib/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ Search.prototype.getIndexes = function(query, callback) {
var indexes = (resp.indexes || []).map(function(indexObject) {
var index = self.index(indexObject.indexId);

if (is.object(resp.indexedField)) {
index.fields = resp.indexedField;
if (is.object(indexObject.indexedField)) {
index.fields = indexObject.indexedField;
}

return index;
Expand Down
9 changes: 4 additions & 5 deletions lib/storage/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,6 @@ Bucket.prototype.makePublic = function(options, callback) {
* @param {object} metadata - The metadata you wish to set.
* @param {function=} callback - The callback function.
* @param {?error} callback.err - An error returned while making this request
* @param {object} callback.metadata - The bucket's metadata.
* @param {object} callback.apiResponse - The full API response.
*
* @example
Expand All @@ -836,7 +835,7 @@ Bucket.prototype.makePublic = function(options, callback) {
* mainPageSuffix: 'http://example.com',
* notFoundPage: 'http://example.com/404.html'
* }
* }, function(err, metadata, apiResponse) {});
* }, function(err, apiResponse) {});
*
* //-
* // Enable versioning for your bucket.
Expand All @@ -845,21 +844,21 @@ Bucket.prototype.makePublic = function(options, callback) {
* versioning: {
* enabled: true
* }
* }, function(err, metadata, apiResponse) {});
* }, function(err, apiResponse) {});
*/
Bucket.prototype.setMetadata = function(metadata, callback) {
var that = this;
callback = callback || util.noop;

this.makeReq_('PATCH', '', null, metadata, function(err, resp) {
if (err) {
callback(err, null, resp);
callback(err, resp);
return;
}

that.metadata = resp;

callback(null, that.metadata, resp);
callback(null, resp);
});
};

Expand Down
13 changes: 6 additions & 7 deletions lib/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,6 @@ File.prototype.getSignedUrl = function(options, callback) {
* @param {object} metadata - The metadata you wish to update.
* @param {function=} callback - The callback function.
* @param {?error} callback.err - An error returned while making this request
* @param {object} callback.metadata - The File's metadata.
* @param {object} callback.apiResponse - The full API response.
*
* @example
Expand All @@ -1274,7 +1273,7 @@ File.prototype.getSignedUrl = function(options, callback) {
* my: 'custom',
* properties: 'go here'
* }
* }, function(err, metadata, apiResponse) {});
* }, function(err, apiResponse) {});
*
* // Assuming current metadata = { hello: 'world', unsetMe: 'will do' }
* file.setMetadata({
Expand All @@ -1283,7 +1282,7 @@ File.prototype.getSignedUrl = function(options, callback) {
* unsetMe: null, // will be unset (deleted).
* hello: 'goodbye' // will be updated from 'hello' to 'goodbye'.
* }
* }, function(err, metadata, apiResponse) {
* }, function(err, apiResponse) {
* // metadata should now be { abc: '123', hello: 'goodbye' }
* });
*/
Expand All @@ -1300,13 +1299,13 @@ File.prototype.setMetadata = function(metadata, callback) {

this.makeReq_('PATCH', path, query, metadata, function(err, resp) {
if (err) {
callback(err, null, resp);
callback(err, resp);
return;
}

that.metadata = resp;

callback(null, that.metadata, resp);
callback(null, resp);
});
};

Expand Down Expand Up @@ -1351,13 +1350,13 @@ File.prototype.makePrivate = function(options, callback) {

this.makeReq_('PATCH', path, query, metadata, function(err, resp) {
if (err) {
callback(err);
callback(err, resp);
return;
}

that.metadata = resp;

callback(null);
callback(null, resp);
});
};

Expand Down
2 changes: 0 additions & 2 deletions system-test/bigquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

/*global describe, it, before, after */

'use strict';

var assert = require('assert');
Expand Down
16 changes: 16 additions & 0 deletions system-test/compute.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var assert = require('assert');
Expand Down
2 changes: 0 additions & 2 deletions system-test/datastore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

/*global describe, it, after, before */

'use strict';

var env = require('./env.js');
Expand Down
24 changes: 9 additions & 15 deletions test/bigquery/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

/*global describe, it, beforeEach */

'use strict';

var arrify = require('arrify');
Expand Down Expand Up @@ -441,13 +439,17 @@ describe('BigQuery/Dataset', function() {
ds.setMetadata(METADATA, assert.ifError);
});

it('should execute callback with error', function(done) {
it('should execute callback with error & API response', function(done) {
var error = new Error('Error.');
var apiResponse = {};

ds.makeReq_ = function(method, path, query, body, callback) {
callback(error);
callback(error, apiResponse);
};
ds.setMetadata(METADATA, function(err) {
assert.equal(err, error);

ds.setMetadata(METADATA, function(err, apiResponse_) {
assert.strictEqual(err, error);
assert.strictEqual(apiResponse_, apiResponse);
done();
});
});
Expand All @@ -467,16 +469,8 @@ describe('BigQuery/Dataset', function() {
});
});

it('should execute callback with metadata', function(done) {
ds.setMetadata(METADATA, function(err, metadata) {
assert.ifError(err);
assert.deepEqual(metadata, METADATA);
done();
});
});

it('should execute callback with apiResponse', function(done) {
ds.setMetadata(METADATA, function(err, metadata, apiResponse) {
ds.setMetadata(METADATA, function(err, apiResponse) {
assert.ifError(err);
assert.deepEqual(apiResponse, METADATA);
done();
Expand Down
2 changes: 0 additions & 2 deletions test/bigquery/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

/*global describe, it, beforeEach */

'use strict';

var assert = require('assert');
Expand Down
Loading