Skip to content

Commit

Permalink
Add unit tests for retries
Browse files Browse the repository at this point in the history
  • Loading branch information
kolodny committed Dec 13, 2017
1 parent 5fa4aa6 commit e561e4f
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions test/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,69 @@ describe('Bigtable/Table', function() {
table.mutate(entries, done);
});
});

describe('retries', function() {
var fakeStatuses;
var entryRequests;

beforeEach(function() {
entryRequests = [];
fakeStatuses = [
[
{
index: 0,
status: {
code: 0,
},
},
{
index: 1,
status: {
code: 4,
},
},
],
[
{
index: 0,
status: {
code: 0,
},
},

]
];
FakeGrpcService.decorateStatus_ = function(status) {
return {};
};
table.requestStream = function(_, reqOpts) {
entryRequests.push(reqOpts.entries);
var stream = new Stream({
objectMode: true,
});

setImmediate(function() {
stream.emit('request');
stream.end({entries: fakeStatuses.shift()});
});

return stream;
};
});

it('should succeed after a retry', function(done) {
table.maxRetries = 1;
table.mutate(entries, done);
});

it('should retry the same failed entry', function(done) {
table.maxRetries = 1;
table.mutate(entries, function() {
assert.strictEqual(entryRequests[0][1], entryRequests[1][0]);
done();
});
});
});
});

describe('row', function() {
Expand Down

0 comments on commit e561e4f

Please sign in to comment.