Skip to content

Commit

Permalink
Use a real Error in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Aug 29, 2016
1 parent 3607c6b commit 6f31226
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 62 deletions.
6 changes: 3 additions & 3 deletions bigquery/test/queries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('bigquery:query', function () {
});

it('should handle error', function () {
var error = Error('syncQueryError');
var error = new Error('error');
var example = getSample();
example.mocks.bigquery.query = sinon.stub().callsArgWith(1, error);
example.program.syncQuery(query, function (err, data) {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('bigquery:query', function () {
});

it('should handle error', function () {
var error = Error('asyncQueryError');
var error = new Error('error');
var example = getSample();
example.mocks.bigquery.startQuery = sinon.stub().callsArgWith(1, error);
example.program.asyncQuery(query, function (err, job) {
Expand Down Expand Up @@ -193,7 +193,7 @@ describe('bigquery:query', function () {
});

it('should handle error', function () {
var error = Error('asyncPollError');
var error = new Error('error');
var example = getSample();
example.mocks.job.getQueryResults = sinon.stub().callsArgWith(0, error);
example.program.asyncPoll(example.jobId, function (err, rows) {
Expand Down
2 changes: 1 addition & 1 deletion bigquery/test/tables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ describe('bigquery:tables', function () {
});

it('should handle export error', function () {
var error = new Error('exportTableToGCSError');
var error = new Error('error');
var example = getSample();
var callback = sinon.stub();
example.mocks.table.export.yields(error);
Expand Down
6 changes: 3 additions & 3 deletions logging/test/logs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('logging:entries', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.logging.getEntries = sinon.stub().callsArgWith(1, error);
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('logging:entries', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.log.write = sinon.stub().callsArgWith(1, error);
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('logging:entries', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.log.delete = sinon.stub().callsArgWith(0, error);
Expand Down
10 changes: 5 additions & 5 deletions logging/test/sinks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('logging:sinks', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.sink.create = sinon.stub().callsArgWith(1, error);
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('logging:sinks', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.sink.getMetadata = sinon.stub().callsArgWith(0, error);
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('logging:sinks', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.logging.getSinks = sinon.stub().callsArgWith(0, error);
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('logging:sinks', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.sink.setMetadata = sinon.stub().callsArgWith(1, error);
Expand Down Expand Up @@ -278,7 +278,7 @@ describe('logging:sinks', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.sink.delete = sinon.stub().callsArgWith(0, error);
Expand Down
24 changes: 12 additions & 12 deletions pubsub/test/iam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ describe('pubsub:iam', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.topic.iam.getPolicy.callsArgWith(0, new Error(error));
var error = new Error('error');
sample.mocks.topic.iam.getPolicy.callsArgWith(0, error);
sample.program.getTopicPolicy(topicName, function (err) {
assert(err);
assert(err.message === 'error');
Expand All @@ -100,8 +100,8 @@ describe('pubsub:iam', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.subscription.iam.getPolicy.callsArgWith(0, new Error(error));
var error = new Error('error');
sample.mocks.subscription.iam.getPolicy.callsArgWith(0, error);
sample.program.getSubscriptionPolicy(subscriptionName, function (err) {
assert(err);
assert(err.message === 'error');
Expand All @@ -128,8 +128,8 @@ describe('pubsub:iam', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.topic.iam.setPolicy.callsArgWith(1, new Error(error));
var error = new Error('error');
sample.mocks.topic.iam.setPolicy.callsArgWith(1, error);
sample.program.setTopicPolicy(topicName, function (err) {
assert(err);
assert(err.message === 'error');
Expand All @@ -156,8 +156,8 @@ describe('pubsub:iam', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.subscription.iam.setPolicy.callsArgWith(1, new Error(error));
var error = new Error('error');
sample.mocks.subscription.iam.setPolicy.callsArgWith(1, error);
sample.program.setSubscriptionPolicy(subscriptionName, function (err) {
assert(err);
assert(err.message === 'error');
Expand All @@ -184,8 +184,8 @@ describe('pubsub:iam', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.topic.iam.testPermissions.callsArgWith(1, new Error(error));
var error = new Error('error');
sample.mocks.topic.iam.testPermissions.callsArgWith(1, error);
sample.program.testTopicPermissions(topicName, function (err, permissions) {
assert(err);
assert(err.message === 'error');
Expand Down Expand Up @@ -213,8 +213,8 @@ describe('pubsub:iam', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.subscription.iam.testPermissions.callsArgWith(1, new Error(error));
var error = new Error('error');
sample.mocks.subscription.iam.testPermissions.callsArgWith(1, error);
sample.program.testSubscriptionPermissions(subscriptionName, function (err, permissions) {
assert(err);
assert(err.message === 'error');
Expand Down
20 changes: 10 additions & 10 deletions pubsub/test/subscriptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ describe('pubsub:subscriptions', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.pubsub.subscribe.callsArgWith(3, new Error(error));
var error = new Error('error');
sample.mocks.pubsub.subscribe.callsArgWith(3, error);
sample.program.createSubscription(topicName, subscriptionName, function (err) {
assert(err);
assert(err.message === 'error');
Expand All @@ -118,8 +118,8 @@ describe('pubsub:subscriptions', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.subscription.delete.callsArgWith(0, new Error(error));
var error = new Error('error');
sample.mocks.subscription.delete.callsArgWith(0, error);
sample.program.deleteSubscription(subscriptionName, function (err) {
assert(err);
assert(err.message === 'error');
Expand All @@ -146,8 +146,8 @@ describe('pubsub:subscriptions', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.pubsub.getSubscriptions.callsArgWith(1, new Error(error));
var error = new Error('error');
sample.mocks.pubsub.getSubscriptions.callsArgWith(1, error);
sample.program.listSubscriptions(undefined, function (err, subscriptions) {
assert(err);
assert(err.message === 'error');
Expand Down Expand Up @@ -176,8 +176,8 @@ describe('pubsub:subscriptions', function () {
});
it('should handle pull error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.subscription.pull.callsArgWith(1, new Error(error));
var error = new Error('error');
sample.mocks.subscription.pull.callsArgWith(1, error);
sample.program.pullMessages(subscriptionName, function (err, messages) {
assert(err);
assert(err.message === 'error');
Expand All @@ -186,8 +186,8 @@ describe('pubsub:subscriptions', function () {
});
it('should handle ack error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.subscription.ack.callsArgWith(1, new Error(error));
var error = new Error('error');
sample.mocks.subscription.ack.callsArgWith(1, error);
sample.program.pullMessages(subscriptionName, function (err) {
assert(err);
assert(err.message === 'error');
Expand Down
16 changes: 8 additions & 8 deletions pubsub/test/topics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ describe('pubsub:topics', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.topic.get.callsArgWith(1, new Error(error));
var error = new Error('error');
sample.mocks.topic.get.callsArgWith(1, error);
sample.program.createTopic(topicName, function (err) {
assert(err);
assert(err.message === 'error');
Expand All @@ -94,8 +94,8 @@ describe('pubsub:topics', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.topic.delete.callsArgWith(0, new Error(error));
var error = new Error('error');
sample.mocks.topic.delete.callsArgWith(0, error);
sample.program.deleteTopic(topicName, function (err) {
assert(err);
assert(err.message === 'error');
Expand Down Expand Up @@ -138,8 +138,8 @@ describe('pubsub:topics', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.topic.publish.callsArgWith(1, new Error(error));
var error = new Error('error');
sample.mocks.topic.publish.callsArgWith(1, error);
sample.program.publishMessage(topicName, '{"data":"hello world"}', function (err, messageIds) {
assert(err);
assert(err.message === 'error');
Expand All @@ -159,8 +159,8 @@ describe('pubsub:topics', function () {
});
it('should handle error', function () {
var sample = getSample();
var error = 'error';
sample.mocks.pubsub.getTopics.callsArgWith(0, new Error(error));
var error = new Error('error');
sample.mocks.pubsub.getTopics.callsArgWith(0, error);
sample.program.listTopics(function (err, topics) {
assert(err);
assert(err.message === 'error');
Expand Down
6 changes: 3 additions & 3 deletions storage/test/acl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('storage:acl', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.bucket.acl.add = sinon.stub().callsArgWith(1, error);
Expand Down Expand Up @@ -263,7 +263,7 @@ describe('storage:acl', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
var options = {
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('storage:acl', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
var options = {
Expand Down
6 changes: 3 additions & 3 deletions storage/test/buckets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('storage:buckets', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.bucket.create = sinon.stub().callsArgWith(0, error);
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('storage:buckets', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.storage.getBuckets = sinon.stub().callsArgWith(0, error);
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('storage:buckets', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
sample.mocks.bucket.delete = sinon.stub().callsArgWith(0, error);
Expand Down
4 changes: 2 additions & 2 deletions storage/test/encryption.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('storage:encryption', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
var options = {
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('storage:encryption', function () {
});

it('should handle error', function () {
var error = 'error';
var error = new Error('error');
var sample = getSample();
var callback = sinon.stub();
var options = {
Expand Down
Loading

0 comments on commit 6f31226

Please sign in to comment.