From 796596ffc335cc9dba88ef94a572fabbd9972d8a Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Tue, 9 Sep 2014 17:08:30 -0400 Subject: [PATCH] storage: privatize `makeReq` --- lib/storage/index.js | 14 ++++++++------ test/storage/index.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/storage/index.js b/lib/storage/index.js index 58b61de8c95..f015556f762 100644 --- a/lib/storage/index.js +++ b/lib/storage/index.js @@ -134,7 +134,7 @@ Bucket.prototype.list = function(query, callback) { callback = query; query = {}; } - this.makeReq('GET', 'o', query, true, function(err, resp) { + this.makeReq_('GET', 'o', query, true, function(err, resp) { if (err) { callback(err); return; @@ -159,7 +159,7 @@ Bucket.prototype.list = function(query, callback) { */ Bucket.prototype.stat = function(name, callback) { var path = util.format('o/{name}', { name: name }); - this.makeReq('GET', path, null, true, callback); + this.makeReq_('GET', path, null, true, callback); }; /** @@ -196,7 +196,7 @@ Bucket.prototype.copy = function(name, metadata, callback) { }); delete metadata.name; delete metadata.bucket; - this.makeReq('POST', path, null, metadata, callback); + this.makeReq_('POST', path, null, metadata, callback); }; /** @@ -210,7 +210,7 @@ Bucket.prototype.copy = function(name, metadata, callback) { */ Bucket.prototype.remove = function(name, callback) { var path = util.format('o/{name}', { name: name }); - this.makeReq('DELETE', path, null, true, callback); + this.makeReq_('DELETE', path, null, true, callback); }; /** @@ -375,7 +375,7 @@ Bucket.prototype.write = function(name, options, callback) { if (typeof data === 'undefined') { // metadata only write - this.makeReq('PATCH', 'o/' + name, null, metadata, callback); + this.makeReq_('PATCH', 'o/' + name, null, metadata, callback); return; } @@ -442,13 +442,15 @@ Bucket.prototype.getWritableStream_ = function(name, metadata, callback) { * Make a new request object from the provided arguments and wrap the callback * to intercept non-successful responses. * + * @private + * * @param {string} method - Action. * @param {string} path - Request path. * @param {*} query - Request query object. * @param {*} body - Request body contents. * @param {function} callback - The callback function. */ -Bucket.prototype.makeReq = function(method, path, query, body, callback) { +Bucket.prototype.makeReq_ = function(method, path, query, body, callback) { var reqOpts = { method: method, qs: query, diff --git a/test/storage/index.js b/test/storage/index.js index d09b1482066..dd1c8548cf5 100644 --- a/test/storage/index.js +++ b/test/storage/index.js @@ -38,7 +38,7 @@ describe('Bucket', function() { it('should list without a query', function(done) { var bucket = createBucket(); - bucket.makeReq = function(method, path, q, body) { + bucket.makeReq_ = function(method, path, q, body) { assert.strictEqual(method, 'GET'); assert.strictEqual(path, 'o'); assert.deepEqual(q, {}); @@ -50,7 +50,7 @@ describe('Bucket', function() { it('should list with a query', function(done) { var bucket = createBucket(); - bucket.makeReq = function(method, path, q, body) { + bucket.makeReq_ = function(method, path, q, body) { assert.strictEqual(method, 'GET'); assert.strictEqual(path, 'o'); assert.deepEqual(q, { maxResults: 5, pageToken: 'token' }); @@ -62,7 +62,7 @@ describe('Bucket', function() { it('should return nextQuery if more results', function() { var bucket = createBucket(); - bucket.makeReq = function(method, path, q, body, callback) { + bucket.makeReq_ = function(method, path, q, body, callback) { callback(null, { nextPageToken: 'next-page-token', items: [] }); }; bucket.list({ maxResults: 5}, function(err, results, nextQuery) { @@ -73,7 +73,7 @@ describe('Bucket', function() { it('should return no nextQuery if no more results', function() { var bucket = createBucket(); - bucket.makeReq = function(method, path, q, body, callback) { + bucket.makeReq_ = function(method, path, q, body, callback) { callback(null, { items: [] }); }; bucket.list({ maxResults: 5}, function(err, results, nextQuery) { @@ -83,7 +83,7 @@ describe('Bucket', function() { it('should stat a file', function(done) { var bucket = createBucket(); - bucket.makeReq = function(method, path, q, body) { + bucket.makeReq_ = function(method, path, q, body) { assert.strictEqual(method, 'GET'); assert.strictEqual(path, 'o/file-name'); assert.strictEqual(q, null); @@ -95,7 +95,7 @@ describe('Bucket', function() { it('should copy a file', function(done) { var bucket = createBucket(); - bucket.makeReq = function(method, path, q, body) { + bucket.makeReq_ = function(method, path, q, body) { assert.strictEqual(method, 'POST'); assert.strictEqual(path, 'o/file-name/copyTo/b/new-bucket/o/new-name'); assert.strictEqual(q, null); @@ -108,7 +108,7 @@ describe('Bucket', function() { it('should use the same bucket if nothing else is provided', function(done) { var bucket = createBucket(); - bucket.makeReq = function(method, path, q, body) { + bucket.makeReq_ = function(method, path, q, body) { assert.strictEqual(method, 'POST'); assert.strictEqual(path, 'o/file-name/copyTo/b/bucket-name/o/new-name'); assert.strictEqual(q, null); @@ -121,7 +121,7 @@ describe('Bucket', function() { it('should remove a file', function(done) { var bucket = createBucket(); - bucket.makeReq = function(method, path, q, body) { + bucket.makeReq_ = function(method, path, q, body) { assert.strictEqual(method, 'DELETE'); assert.strictEqual(path, 'o/file-name'); assert.strictEqual(q, null);