Skip to content

Commit 3713fa5

Browse files
tests: cover datastore/request leaks
tests: cover bigquery/table leaks tests: cover datastore/transaction leaks tests: cover datastore/dataset leaks tests: cover storage/file leaks tests: cover storage/bucket leaks tests: cover search/index leaks tests: cover storage/acl leaks tests: cover dns/zone leaks tests: cover datastore/entity leaks tests: cover pubsub/subscription leaks
1 parent 469c3ac commit 3713fa5

28 files changed

+490
-148
lines changed

lib/bigquery/dataset.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Dataset.prototype.delete = function(options, callback) {
159159
*
160160
* @param {function} callback - The callback function.
161161
* @param {?error} callback.err - An error returned while making this request
162-
* @param {object} callback.metadata - The Dataset metadata
162+
* @param {object} callback.metadata - The dataset's metadata.
163163
* @param {object} callback.apiResponse - The full API response.
164164
*
165165
* @example
@@ -284,28 +284,27 @@ Dataset.prototype.query = function(options, callback) {
284284
* @param {object} metadata - Metadata to save on the Dataset.
285285
* @param {function} callback - The callback function.
286286
* @param {?error} callback.err - An error returned while making this request
287-
* @param {object} callback.metadata - The metadata of the Dataset object.
288-
* @param {object} callback.apiResponse - The full API response.
287+
* @param {object} callback.apiResponse - The full API response.
289288
*
290289
* @example
291290
* var metadata = {
292291
* description: 'Information for every institution in the 2013 IPEDS universe'
293292
* };
294293
*
295-
* dataset.setMetadata(metadata, function(err, metadata, apiResponse) {});
294+
* dataset.setMetadata(metadata, function(err, apiResponse) {});
296295
*/
297296
Dataset.prototype.setMetadata = function(metadata, callback) {
298297
var that = this;
299298

300299
this.makeReq_('PATCH', '', null, metadata, function(err, resp) {
301300
if (err) {
302-
callback(err, null, resp);
301+
callback(err, resp);
303302
return;
304303
}
305304

306305
that.metadata = resp;
307306

308-
callback(null, that.metadata, resp);
307+
callback(null, resp);
309308
});
310309
};
311310

lib/bigquery/table.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,9 @@ Table.prototype.getRows = function(options, callback) {
587587

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

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

893892
this.makeReq_('PUT', '', null, metadata, function(err, resp) {
894893
if (err) {
895-
callback(err, null, resp);
894+
callback(err, resp);
896895
return;
897896
}
898897

899898
that.metadata = resp;
900899

901-
callback(null, that.metadata, resp);
900+
callback(null, resp);
902901
});
903902
};
904903

lib/compute/firewall.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Firewall.prototype.delete = function(callback) {
103103
*
104104
* @param {function=} callback - The callback function.
105105
* @param {?error} callback.err - An error returned while making this request
106-
* @param {object} callback.metadata - The network's metadata.
106+
* @param {object} callback.metadata - The firewall's metadata.
107107
* @param {object} callback.apiResponse - The full API response.
108108
*
109109
* @example

lib/compute/snapshot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Snapshot.prototype.delete = function(callback) {
100100
*
101101
* @param {function=} callback - The callback function.
102102
* @param {?error} callback.err - An error returned while making this request
103-
* @param {object} callback.metadata - The zone's metadata.
103+
* @param {object} callback.metadata - The snapshot's metadata.
104104
* @param {object} callback.apiResponse - The full API response.
105105
*
106106
* @example

lib/datastore/dataset.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,14 @@ Dataset.prototype.createQuery = function(namespace, kind) {
244244
*
245245
* done();
246246
* });
247-
* }, function(err) {});
247+
* }, function(err, apiResponse) {});
248248
*/
249249
Dataset.prototype.runInTransaction = function(fn, callback) {
250250
var newTransaction = this.createTransaction_();
251251

252-
newTransaction.begin_(function(err) {
252+
newTransaction.begin_(function(err, resp) {
253253
if (err) {
254-
callback(err);
254+
callback(err, resp);
255255
return;
256256
}
257257

lib/datastore/transaction.js

-11
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,4 @@ Transaction.prototype.save = function(entities) {
383383
});
384384
};
385385

386-
/**
387-
* mapQuery
388-
*
389-
* @todo Implement.
390-
*
391-
* @private
392-
*/
393-
Transaction.prototype.mapQuery = function() {
394-
throw new Error('not yet implemented');
395-
};
396-
397386
module.exports = Transaction;

lib/search/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ Search.prototype.getIndexes = function(query, callback) {
197197
var indexes = (resp.indexes || []).map(function(indexObject) {
198198
var index = self.index(indexObject.indexId);
199199

200-
if (is.object(resp.indexedField)) {
201-
index.fields = resp.indexedField;
200+
if (is.object(indexObject.indexedField)) {
201+
index.fields = indexObject.indexedField;
202202
}
203203

204204
return index;

lib/storage/bucket.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@ Bucket.prototype.makePublic = function(options, callback) {
824824
* @param {object} metadata - The metadata you wish to set.
825825
* @param {function=} callback - The callback function.
826826
* @param {?error} callback.err - An error returned while making this request
827-
* @param {object} callback.metadata - The bucket's metadata.
828827
* @param {object} callback.apiResponse - The full API response.
829828
*
830829
* @example
@@ -836,7 +835,7 @@ Bucket.prototype.makePublic = function(options, callback) {
836835
* mainPageSuffix: 'http://example.com',
837836
* notFoundPage: 'http://example.com/404.html'
838837
* }
839-
* }, function(err, metadata, apiResponse) {});
838+
* }, function(err, apiResponse) {});
840839
*
841840
* //-
842841
* // Enable versioning for your bucket.
@@ -845,21 +844,21 @@ Bucket.prototype.makePublic = function(options, callback) {
845844
* versioning: {
846845
* enabled: true
847846
* }
848-
* }, function(err, metadata, apiResponse) {});
847+
* }, function(err, apiResponse) {});
849848
*/
850849
Bucket.prototype.setMetadata = function(metadata, callback) {
851850
var that = this;
852851
callback = callback || util.noop;
853852

854853
this.makeReq_('PATCH', '', null, metadata, function(err, resp) {
855854
if (err) {
856-
callback(err, null, resp);
855+
callback(err, resp);
857856
return;
858857
}
859858

860859
that.metadata = resp;
861860

862-
callback(null, that.metadata, resp);
861+
callback(null, resp);
863862
});
864863
};
865864

lib/storage/file.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,6 @@ File.prototype.getSignedUrl = function(options, callback) {
12641264
* @param {object} metadata - The metadata you wish to update.
12651265
* @param {function=} callback - The callback function.
12661266
* @param {?error} callback.err - An error returned while making this request
1267-
* @param {object} callback.metadata - The File's metadata.
12681267
* @param {object} callback.apiResponse - The full API response.
12691268
*
12701269
* @example
@@ -1274,7 +1273,7 @@ File.prototype.getSignedUrl = function(options, callback) {
12741273
* my: 'custom',
12751274
* properties: 'go here'
12761275
* }
1277-
* }, function(err, metadata, apiResponse) {});
1276+
* }, function(err, apiResponse) {});
12781277
*
12791278
* // Assuming current metadata = { hello: 'world', unsetMe: 'will do' }
12801279
* file.setMetadata({
@@ -1283,7 +1282,7 @@ File.prototype.getSignedUrl = function(options, callback) {
12831282
* unsetMe: null, // will be unset (deleted).
12841283
* hello: 'goodbye' // will be updated from 'hello' to 'goodbye'.
12851284
* }
1286-
* }, function(err, metadata, apiResponse) {
1285+
* }, function(err, apiResponse) {
12871286
* // metadata should now be { abc: '123', hello: 'goodbye' }
12881287
* });
12891288
*/
@@ -1300,13 +1299,13 @@ File.prototype.setMetadata = function(metadata, callback) {
13001299

13011300
this.makeReq_('PATCH', path, query, metadata, function(err, resp) {
13021301
if (err) {
1303-
callback(err, null, resp);
1302+
callback(err, resp);
13041303
return;
13051304
}
13061305

13071306
that.metadata = resp;
13081307

1309-
callback(null, that.metadata, resp);
1308+
callback(null, resp);
13101309
});
13111310
};
13121311

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

13521351
this.makeReq_('PATCH', path, query, metadata, function(err, resp) {
13531352
if (err) {
1354-
callback(err);
1353+
callback(err, resp);
13551354
return;
13561355
}
13571356

13581357
that.metadata = resp;
13591358

1360-
callback(null);
1359+
callback(null, resp);
13611360
});
13621361
};
13631362

system-test/bigquery.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
/*global describe, it, before, after */
18-
1917
'use strict';
2018

2119
var assert = require('assert');

system-test/compute.js

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* Copyright 2015 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
'use strict';
218

319
var assert = require('assert');

system-test/datastore.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
/*global describe, it, after, before */
18-
1917
'use strict';
2018

2119
var env = require('./env.js');

test/bigquery/dataset.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
/*global describe, it, beforeEach */
18-
1917
'use strict';
2018

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

444-
it('should execute callback with error', function(done) {
442+
it('should execute callback with error & API response', function(done) {
445443
var error = new Error('Error.');
444+
var apiResponse = {};
445+
446446
ds.makeReq_ = function(method, path, query, body, callback) {
447-
callback(error);
447+
callback(error, apiResponse);
448448
};
449-
ds.setMetadata(METADATA, function(err) {
450-
assert.equal(err, error);
449+
450+
ds.setMetadata(METADATA, function(err, apiResponse_) {
451+
assert.strictEqual(err, error);
452+
assert.strictEqual(apiResponse_, apiResponse);
451453
done();
452454
});
453455
});
@@ -467,16 +469,8 @@ describe('BigQuery/Dataset', function() {
467469
});
468470
});
469471

470-
it('should execute callback with metadata', function(done) {
471-
ds.setMetadata(METADATA, function(err, metadata) {
472-
assert.ifError(err);
473-
assert.deepEqual(metadata, METADATA);
474-
done();
475-
});
476-
});
477-
478472
it('should execute callback with apiResponse', function(done) {
479-
ds.setMetadata(METADATA, function(err, metadata, apiResponse) {
473+
ds.setMetadata(METADATA, function(err, apiResponse) {
480474
assert.ifError(err);
481475
assert.deepEqual(apiResponse, METADATA);
482476
done();

test/bigquery/job.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
/*global describe, it, beforeEach */
18-
1917
'use strict';
2018

2119
var assert = require('assert');

0 commit comments

Comments
 (0)