Skip to content

Commit 1fe093a

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 1fe093a

26 files changed

+481
-139
lines changed

lib/bigquery/dataset.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,20 @@ Dataset.prototype.query = function(options, callback) {
292292
* description: 'Information for every institution in the 2013 IPEDS universe'
293293
* };
294294
*
295-
* dataset.setMetadata(metadata, function(err, metadata, apiResponse) {});
295+
* dataset.setMetadata(metadata, function(err, apiResponse) {});
296296
*/
297297
Dataset.prototype.setMetadata = function(metadata, callback) {
298298
var that = this;
299299

300300
this.makeReq_('PATCH', '', null, metadata, function(err, resp) {
301301
if (err) {
302-
callback(err, null, resp);
302+
callback(err, resp);
303303
return;
304304
}
305305

306306
that.metadata = resp;
307307

308-
callback(null, that.metadata, resp);
308+
callback(null, resp);
309309
});
310310
};
311311

lib/bigquery/table.js

+4-4
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

@@ -892,13 +892,13 @@ Table.prototype.setMetadata = function(metadata, callback) {
892892

893893
this.makeReq_('PUT', '', null, metadata, function(err, resp) {
894894
if (err) {
895-
callback(err, null, resp);
895+
callback(err, resp);
896896
return;
897897
}
898898

899899
that.metadata = resp;
900900

901-
callback(null, that.metadata, resp);
901+
callback(null, resp);
902902
});
903903
};
904904

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-4
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ Bucket.prototype.makePublic = function(options, callback) {
836836
* mainPageSuffix: 'http://example.com',
837837
* notFoundPage: 'http://example.com/404.html'
838838
* }
839-
* }, function(err, metadata, apiResponse) {});
839+
* }, function(err, apiResponse) {});
840840
*
841841
* //-
842842
* // Enable versioning for your bucket.
@@ -845,21 +845,21 @@ Bucket.prototype.makePublic = function(options, callback) {
845845
* versioning: {
846846
* enabled: true
847847
* }
848-
* }, function(err, metadata, apiResponse) {});
848+
* }, function(err, apiResponse) {});
849849
*/
850850
Bucket.prototype.setMetadata = function(metadata, callback) {
851851
var that = this;
852852
callback = callback || util.noop;
853853

854854
this.makeReq_('PATCH', '', null, metadata, function(err, resp) {
855855
if (err) {
856-
callback(err, null, resp);
856+
callback(err, resp);
857857
return;
858858
}
859859

860860
that.metadata = resp;
861861

862-
callback(null, that.metadata, resp);
862+
callback(null, resp);
863863
});
864864
};
865865

lib/storage/file.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ File.prototype.getSignedUrl = function(options, callback) {
12741274
* my: 'custom',
12751275
* properties: 'go here'
12761276
* }
1277-
* }, function(err, metadata, apiResponse) {});
1277+
* }, function(err, apiResponse) {});
12781278
*
12791279
* // Assuming current metadata = { hello: 'world', unsetMe: 'will do' }
12801280
* file.setMetadata({
@@ -1283,7 +1283,7 @@ File.prototype.getSignedUrl = function(options, callback) {
12831283
* unsetMe: null, // will be unset (deleted).
12841284
* hello: 'goodbye' // will be updated from 'hello' to 'goodbye'.
12851285
* }
1286-
* }, function(err, metadata, apiResponse) {
1286+
* }, function(err, apiResponse) {
12871287
* // metadata should now be { abc: '123', hello: 'goodbye' }
12881288
* });
12891289
*/
@@ -1300,13 +1300,13 @@ File.prototype.setMetadata = function(metadata, callback) {
13001300

13011301
this.makeReq_('PATCH', path, query, metadata, function(err, resp) {
13021302
if (err) {
1303-
callback(err, null, resp);
1303+
callback(err, resp);
13041304
return;
13051305
}
13061306

13071307
that.metadata = resp;
13081308

1309-
callback(null, that.metadata, resp);
1309+
callback(null, resp);
13101310
});
13111311
};
13121312

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

13521352
this.makeReq_('PATCH', path, query, metadata, function(err, resp) {
13531353
if (err) {
1354-
callback(err);
1354+
callback(err, resp);
13551355
return;
13561356
}
13571357

13581358
that.metadata = resp;
13591359

1360-
callback(null);
1360+
callback(null, resp);
13611361
});
13621362
};
13631363

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)