Skip to content

Commit

Permalink
tests: cover datastore/request leaks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stephenplusplus committed Sep 17, 2015
1 parent 469c3ac commit 1fe093a
Show file tree
Hide file tree
Showing 26 changed files with 481 additions and 139 deletions.
6 changes: 3 additions & 3 deletions lib/bigquery/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,20 @@ Dataset.prototype.query = function(options, callback) {
* description: 'Information for every institution in the 2013 IPEDS universe'
* };
*
* dataset.setMetadata(metadata, function(err, metadata, apiResponse) {});
* dataset.setMetadata(metadata, function(err, apiResponse) {});
*/
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
8 changes: 4 additions & 4 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 @@ -892,13 +892,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
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
8 changes: 4 additions & 4 deletions lib/storage/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,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 +845,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
12 changes: 6 additions & 6 deletions lib/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,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 +1283,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 +1300,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 +1351,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

0 comments on commit 1fe093a

Please sign in to comment.