From b78c6052ca57308f12569e71bbb91f4690df1125 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sat, 27 Aug 2016 17:26:06 -0700 Subject: [PATCH] Address comments. --- pubsub/system-test/subscriptions.test.js | 18 +++--- pubsub/system-test/topics.test.js | 16 ++--- storage/test/files.test.js | 79 ++++++++++++------------ storage/test/transfer.test.js | 10 +-- 4 files changed, 62 insertions(+), 61 deletions(-) diff --git a/pubsub/system-test/subscriptions.test.js b/pubsub/system-test/subscriptions.test.js index 64cc699d33d..d19aceab759 100644 --- a/pubsub/system-test/subscriptions.test.js +++ b/pubsub/system-test/subscriptions.test.js @@ -33,9 +33,9 @@ describe('pubsub:subscriptions', function () { pubsub.topic(topicName).delete(done); }); - describe('create', function () { + describe('createSubscription', function () { it('should create a subscription', function (done) { - program.create(topicName, subscriptionName, function (err, subscription) { + program.createSubscription(topicName, subscriptionName, function (err, subscription) { assert.ifError(err); assert.equal(subscription.name, name); assert(console.log.calledWith('Created subscription %s to topic %s', subscriptionName, topicName)); @@ -45,9 +45,9 @@ describe('pubsub:subscriptions', function () { }); }); - describe('list', function () { + describe('listSubscriptions', function () { it('should list subscriptions', function (done) { - program.list(topicName, function (err, subscriptions) { + program.listSubscriptions(topicName, function (err, subscriptions) { assert.ifError(err); assert(Array.isArray(subscriptions)); assert(subscriptions.length > 0); @@ -57,7 +57,7 @@ describe('pubsub:subscriptions', function () { assert.equal(recentlyCreatedSubscriptions.length, 1, 'list has newly created subscription'); assert(console.log.calledWith('Found %d subscriptions!', subscriptions.length)); - program.list(undefined, function (err, allSubscriptions) { + program.listSubscriptions(undefined, function (err, allSubscriptions) { assert.ifError(err); assert(Array.isArray(allSubscriptions)); assert(allSubscriptions.length > 0); @@ -72,7 +72,7 @@ describe('pubsub:subscriptions', function () { }); }); - describe('pull', function () { + describe('pullMessages', function () { var expected = 'Hello World!'; before(function (done) { @@ -80,7 +80,7 @@ describe('pubsub:subscriptions', function () { }); it('should pull messages', function (done) { - program.pull(subscriptionName, function (err, messages) { + program.pullMessages(subscriptionName, function (err, messages) { assert.ifError(err); assert(Array.isArray(messages)); assert(messages.length > 0); @@ -92,9 +92,9 @@ describe('pubsub:subscriptions', function () { }); }); - describe('delete', function () { + describe('deleteSubscription', function () { it('should delete a subscription', function (done) { - program.delete(subscriptionName, function (err) { + program.deleteSubscription(subscriptionName, function (err) { assert.ifError(err); assert(console.log.calledWith('Deleted subscription: %s', subscriptionName)); done(); diff --git a/pubsub/system-test/topics.test.js b/pubsub/system-test/topics.test.js index fc178fb3f46..62704a44402 100644 --- a/pubsub/system-test/topics.test.js +++ b/pubsub/system-test/topics.test.js @@ -20,9 +20,9 @@ var projectId = process.env.GCLOUD_PROJECT; var name = 'projects/' + projectId + '/topics/' + topicName; describe('pubsub:topics', function () { - describe('create', function () { + describe('createTopic', function () { it('should create a topic', function (done) { - program.create(topicName, function (err, topic) { + program.createTopic(topicName, function (err, topic) { assert.ifError(err); assert.equal(topic.name, name); assert(console.log.calledWith('Created topic: %s', topicName)); @@ -31,9 +31,9 @@ describe('pubsub:topics', function () { }); }); - describe('list', function () { + describe('listTopics', function () { it('should list topics', function (done) { - program.list(function (err, topics) { + program.listTopics(function (err, topics) { assert.ifError(err); assert(Array.isArray(topics)); assert(topics.length > 0); @@ -47,10 +47,10 @@ describe('pubsub:topics', function () { }); }); - describe('publish', function () { + describe('publishMessage', function () { it('should publish a message', function (done) { var json = '{"data":"Hello World!"}'; - program.publish(topicName, json, function (err, messageIds) { + program.publishMessage(topicName, json, function (err, messageIds) { assert.ifError(err); assert(Array.isArray(messageIds)); assert(messageIds.length > 0); @@ -60,9 +60,9 @@ describe('pubsub:topics', function () { }); }); - describe('delete', function () { + describe('deleteTopic', function () { it('should delete a topic', function (done) { - program.delete(topicName, function (err) { + program.deleteTopic(topicName, function (err) { assert.ifError(err); assert(console.log.calledWith('Deleted topic: %s', topicName)); done(); diff --git a/storage/test/files.test.js b/storage/test/files.test.js index 06a42b606d0..4a220921489 100644 --- a/storage/test/files.test.js +++ b/storage/test/files.test.js @@ -15,9 +15,10 @@ var proxyquire = require('proxyquire').noCallThru(); var bucketName = 'foo'; -var fileName = 'test1.txt'; -var movedFileName = 'test2.txt'; -var copiedFileName = 'test3.txt'; +var srcFileName = 'test1.txt'; +var destFileName = 'test2.txt'; +var movedFileName = 'test3.txt'; +var copiedFileName = 'test4.txt'; function getSample () { var filesMock = [ @@ -168,14 +169,14 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - srcFile: fileName + srcFile: srcFileName }; sample.program.uploadFile(options, callback); assert(sample.mocks.bucket.upload.calledOnce, 'upload called once'); assert.equal(sample.mocks.bucket.upload.firstCall.args.length, 2, 'upload received 2 arguments'); - assert.deepEqual(sample.mocks.bucket.upload.firstCall.args[0], fileName, 'upload received file name'); + assert.deepEqual(sample.mocks.bucket.upload.firstCall.args[0], srcFileName, 'upload received file name'); assert(callback.calledOnce, 'callback called once'); assert.equal(callback.firstCall.args.length, 2, 'callback received 2 arguments'); assert.ifError(callback.firstCall.args[0], 'callback did not receive error'); @@ -189,7 +190,7 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - srcFile: fileName + srcFile: srcFileName }; sample.mocks.bucket.upload = sinon.stub().callsArgWith(1, error); @@ -208,8 +209,8 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - srcFile: fileName, - destFile: fileName + srcFile: srcFileName, + destFile: destFileName }; sample.program.downloadFile(options, callback); @@ -231,8 +232,8 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - srcFile: fileName, - destFile: fileName + srcFile: srcFileName, + destFile: destFileName }; sample.mocks.file.download = sinon.stub().callsArgWith(1, error); @@ -251,7 +252,7 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - file: fileName + file: srcFileName }; sample.program.deleteFile(options, callback); @@ -270,7 +271,7 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - file: fileName + file: srcFileName }; sample.mocks.file.delete = sinon.stub().callsArgWith(0, error); @@ -289,7 +290,7 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - file: fileName + file: srcFileName }; sample.program.getMetadata(options, callback); @@ -309,7 +310,7 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - file: fileName + file: srcFileName }; sample.mocks.file.getMetadata = sinon.stub().callsArgWith(0, error); @@ -328,7 +329,7 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - file: fileName + file: srcFileName }; sample.program.makePublic(options, callback); @@ -347,7 +348,7 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - file: fileName + file: srcFileName }; sample.mocks.file.makePublic = sinon.stub().callsArgWith(0, error); @@ -366,8 +367,8 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - srcFile: fileName, - destFile: fileName + srcFile: srcFileName, + destFile: movedFileName }; sample.program.moveFile(options, callback); @@ -388,8 +389,8 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { bucket: bucketName, - srcFile: fileName, - destFile: fileName + srcFile: srcFileName, + destFile: movedFileName }; sample.mocks.file.move = sinon.stub().callsArgWith(1, error); @@ -408,8 +409,8 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { srcBucket: bucketName, - srcFile: fileName, - destFile: fileName, + srcFile: srcFileName, + destFile: copiedFileName, destBucket: bucketName }; @@ -430,8 +431,8 @@ describe('storage:files', function () { var callback = sinon.stub(); var options = { srcBucket: bucketName, - srcFile: fileName, - destFile: fileName, + srcFile: srcFileName, + destFile: copiedFileName, destBucket: bucketName }; sample.mocks.file.copy = sinon.stub().callsArgWith(1, error); @@ -472,11 +473,11 @@ describe('storage:files', function () { var program = getSample().program; sinon.stub(program, 'uploadFile'); - program.main(['upload', bucketName, fileName]); + program.main(['upload', bucketName, srcFileName]); assert.equal(program.uploadFile.calledOnce, true); assert.deepEqual(program.uploadFile.firstCall.args.slice(0, -1), [{ bucket: bucketName, - srcFile: fileName + srcFile: srcFileName }]); }); @@ -484,12 +485,12 @@ describe('storage:files', function () { var program = getSample().program; sinon.stub(program, 'downloadFile'); - program.main(['download', bucketName, fileName, fileName]); + program.main(['download', bucketName, srcFileName, destFileName]); assert.equal(program.downloadFile.calledOnce, true); assert.deepEqual(program.downloadFile.firstCall.args.slice(0, -1), [{ bucket: bucketName, - srcFile: fileName, - destFile: fileName + srcFile: srcFileName, + destFile: destFileName }]); }); @@ -497,11 +498,11 @@ describe('storage:files', function () { var program = getSample().program; sinon.stub(program, 'deleteFile'); - program.main(['delete', bucketName, fileName]); + program.main(['delete', bucketName, srcFileName]); assert.equal(program.deleteFile.calledOnce, true); assert.deepEqual(program.deleteFile.firstCall.args.slice(0, -1), [{ bucket: bucketName, - file: fileName + file: srcFileName }]); }); @@ -509,11 +510,11 @@ describe('storage:files', function () { var program = getSample().program; sinon.stub(program, 'getMetadata'); - program.main(['getMetadata', bucketName, fileName]); + program.main(['getMetadata', bucketName, srcFileName]); assert.equal(program.getMetadata.calledOnce, true); assert.deepEqual(program.getMetadata.firstCall.args.slice(0, -1), [{ bucket: bucketName, - file: fileName + file: srcFileName }]); }); @@ -521,11 +522,11 @@ describe('storage:files', function () { var program = getSample().program; sinon.stub(program, 'makePublic'); - program.main(['makePublic', bucketName, fileName]); + program.main(['makePublic', bucketName, srcFileName]); assert.equal(program.makePublic.calledOnce, true); assert.deepEqual(program.makePublic.firstCall.args.slice(0, -1), [{ bucket: bucketName, - file: fileName + file: srcFileName }]); }); @@ -533,11 +534,11 @@ describe('storage:files', function () { var program = getSample().program; sinon.stub(program, 'moveFile'); - program.main(['move', bucketName, fileName, movedFileName]); + program.main(['move', bucketName, srcFileName, movedFileName]); assert.equal(program.moveFile.calledOnce, true); assert.deepEqual(program.moveFile.firstCall.args.slice(0, -1), [{ bucket: bucketName, - srcFile: fileName, + srcFile: srcFileName, destFile: movedFileName }]); }); @@ -546,11 +547,11 @@ describe('storage:files', function () { var program = getSample().program; sinon.stub(program, 'copyFile'); - program.main(['copy', bucketName, fileName, bucketName, copiedFileName]); + program.main(['copy', bucketName, srcFileName, bucketName, copiedFileName]); assert.equal(program.copyFile.calledOnce, true); assert.deepEqual(program.copyFile.firstCall.args.slice(0, -1), [{ srcBucket: bucketName, - srcFile: fileName, + srcFile: srcFileName, destBucket: bucketName, destFile: copiedFileName }]); diff --git a/storage/test/transfer.test.js b/storage/test/transfer.test.js index 7cdc702cc5f..e8a89e165ec 100644 --- a/storage/test/transfer.test.js +++ b/storage/test/transfer.test.js @@ -14,7 +14,7 @@ 'use strict'; var proxyquire = require('proxyquire').noCallThru(); -var bucketName = 'foo'; +var srcBucketName = 'foo'; var destBucketName = 'bar'; var jobName = 'transferJobs/123456789012345678'; var transferOperationName = 'transferOperations/123456789012345678'; @@ -69,8 +69,8 @@ describe('storage:transfer', function () { var date = '2016/08/11'; var time = '15:30'; var options = { - srcBucket: bucketName, - destBucket: bucketName, + srcBucket: srcBucketName, + destBucket: destBucketName, date: date, time: time }; @@ -485,10 +485,10 @@ describe('storage:transfer', function () { var program = getSample().program; sinon.stub(program, 'createTransferJob'); - program.main(['jobs', 'create', bucketName, destBucketName, 'time', 'date']); + program.main(['jobs', 'create', srcBucketName, destBucketName, 'time', 'date']); assert.equal(program.createTransferJob.calledOnce, true); assert.deepEqual(program.createTransferJob.firstCall.args.slice(0, -1), [{ - srcBucket: bucketName, + srcBucket: srcBucketName, destBucket: destBucketName, time: 'time', date: 'date',