Skip to content

Commit ffa60ee

Browse files
author
Burcu Dogan
committed
Merge pull request #199 from stephenplusplus/hide-makereq
storage: privatize `makeReq`
2 parents a56903a + 796596f commit ffa60ee

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

lib/storage/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Bucket.prototype.list = function(query, callback) {
134134
callback = query;
135135
query = {};
136136
}
137-
this.makeReq('GET', 'o', query, true, function(err, resp) {
137+
this.makeReq_('GET', 'o', query, true, function(err, resp) {
138138
if (err) {
139139
callback(err);
140140
return;
@@ -159,7 +159,7 @@ Bucket.prototype.list = function(query, callback) {
159159
*/
160160
Bucket.prototype.stat = function(name, callback) {
161161
var path = util.format('o/{name}', { name: name });
162-
this.makeReq('GET', path, null, true, callback);
162+
this.makeReq_('GET', path, null, true, callback);
163163
};
164164

165165
/**
@@ -196,7 +196,7 @@ Bucket.prototype.copy = function(name, metadata, callback) {
196196
});
197197
delete metadata.name;
198198
delete metadata.bucket;
199-
this.makeReq('POST', path, null, metadata, callback);
199+
this.makeReq_('POST', path, null, metadata, callback);
200200
};
201201

202202
/**
@@ -210,7 +210,7 @@ Bucket.prototype.copy = function(name, metadata, callback) {
210210
*/
211211
Bucket.prototype.remove = function(name, callback) {
212212
var path = util.format('o/{name}', { name: name });
213-
this.makeReq('DELETE', path, null, true, callback);
213+
this.makeReq_('DELETE', path, null, true, callback);
214214
};
215215

216216
/**
@@ -375,7 +375,7 @@ Bucket.prototype.write = function(name, options, callback) {
375375

376376
if (typeof data === 'undefined') {
377377
// metadata only write
378-
this.makeReq('PATCH', 'o/' + name, null, metadata, callback);
378+
this.makeReq_('PATCH', 'o/' + name, null, metadata, callback);
379379
return;
380380
}
381381

@@ -442,13 +442,15 @@ Bucket.prototype.getWritableStream_ = function(name, metadata, callback) {
442442
* Make a new request object from the provided arguments and wrap the callback
443443
* to intercept non-successful responses.
444444
*
445+
* @private
446+
*
445447
* @param {string} method - Action.
446448
* @param {string} path - Request path.
447449
* @param {*} query - Request query object.
448450
* @param {*} body - Request body contents.
449451
* @param {function} callback - The callback function.
450452
*/
451-
Bucket.prototype.makeReq = function(method, path, query, body, callback) {
453+
Bucket.prototype.makeReq_ = function(method, path, query, body, callback) {
452454
var reqOpts = {
453455
method: method,
454456
qs: query,

test/storage/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Bucket', function() {
3838

3939
it('should list without a query', function(done) {
4040
var bucket = createBucket();
41-
bucket.makeReq = function(method, path, q, body) {
41+
bucket.makeReq_ = function(method, path, q, body) {
4242
assert.strictEqual(method, 'GET');
4343
assert.strictEqual(path, 'o');
4444
assert.deepEqual(q, {});
@@ -50,7 +50,7 @@ describe('Bucket', function() {
5050

5151
it('should list with a query', function(done) {
5252
var bucket = createBucket();
53-
bucket.makeReq = function(method, path, q, body) {
53+
bucket.makeReq_ = function(method, path, q, body) {
5454
assert.strictEqual(method, 'GET');
5555
assert.strictEqual(path, 'o');
5656
assert.deepEqual(q, { maxResults: 5, pageToken: 'token' });
@@ -62,7 +62,7 @@ describe('Bucket', function() {
6262

6363
it('should return nextQuery if more results', function() {
6464
var bucket = createBucket();
65-
bucket.makeReq = function(method, path, q, body, callback) {
65+
bucket.makeReq_ = function(method, path, q, body, callback) {
6666
callback(null, { nextPageToken: 'next-page-token', items: [] });
6767
};
6868
bucket.list({ maxResults: 5}, function(err, results, nextQuery) {
@@ -73,7 +73,7 @@ describe('Bucket', function() {
7373

7474
it('should return no nextQuery if no more results', function() {
7575
var bucket = createBucket();
76-
bucket.makeReq = function(method, path, q, body, callback) {
76+
bucket.makeReq_ = function(method, path, q, body, callback) {
7777
callback(null, { items: [] });
7878
};
7979
bucket.list({ maxResults: 5}, function(err, results, nextQuery) {
@@ -83,7 +83,7 @@ describe('Bucket', function() {
8383

8484
it('should stat a file', function(done) {
8585
var bucket = createBucket();
86-
bucket.makeReq = function(method, path, q, body) {
86+
bucket.makeReq_ = function(method, path, q, body) {
8787
assert.strictEqual(method, 'GET');
8888
assert.strictEqual(path, 'o/file-name');
8989
assert.strictEqual(q, null);
@@ -95,7 +95,7 @@ describe('Bucket', function() {
9595

9696
it('should copy a file', function(done) {
9797
var bucket = createBucket();
98-
bucket.makeReq = function(method, path, q, body) {
98+
bucket.makeReq_ = function(method, path, q, body) {
9999
assert.strictEqual(method, 'POST');
100100
assert.strictEqual(path, 'o/file-name/copyTo/b/new-bucket/o/new-name');
101101
assert.strictEqual(q, null);
@@ -108,7 +108,7 @@ describe('Bucket', function() {
108108

109109
it('should use the same bucket if nothing else is provided', function(done) {
110110
var bucket = createBucket();
111-
bucket.makeReq = function(method, path, q, body) {
111+
bucket.makeReq_ = function(method, path, q, body) {
112112
assert.strictEqual(method, 'POST');
113113
assert.strictEqual(path, 'o/file-name/copyTo/b/bucket-name/o/new-name');
114114
assert.strictEqual(q, null);
@@ -121,7 +121,7 @@ describe('Bucket', function() {
121121

122122
it('should remove a file', function(done) {
123123
var bucket = createBucket();
124-
bucket.makeReq = function(method, path, q, body) {
124+
bucket.makeReq_ = function(method, path, q, body) {
125125
assert.strictEqual(method, 'DELETE');
126126
assert.strictEqual(path, 'o/file-name');
127127
assert.strictEqual(q, null);

0 commit comments

Comments
 (0)