Skip to content

Commit 368cde6

Browse files
bigtable: tests & docs
1 parent 536e286 commit 368cde6

File tree

3 files changed

+28
-41
lines changed

3 files changed

+28
-41
lines changed

packages/bigtable/src/table.js

+14-22
Original file line numberDiff line numberDiff line change
@@ -683,30 +683,21 @@ Table.prototype.getRows = function(options, callback) {
683683
* See {module:bigtable/table#mutate}.
684684
* @param {function} callback - The callback function.
685685
* @param {?error} callback.err - An error returned while making this request.
686-
* @param {object[]} callback.insertErrors - A status object for each failed
687-
* insert.
686+
* @param {object[]} callback.err.errors - If present, these represent partial
687+
* failures. It's possible for part of your request to be completed
688+
* successfully, while the other part was not.
688689
*
689690
* @example
690-
* var callback = function(err, insertErrors) {
691+
* var callback = function(err) {
691692
* if (err) {
692-
* // Error handling omitted.
693-
* }
693+
* // An API error or partial failure occurred.
694694
*
695-
* // insertErrors = [
696-
* // {
697-
* // code: 500,
698-
* // message: 'Internal Server Error',
699-
* // entry: {
700-
* // key: 'gwashington',
701-
* // data: {
702-
* // follows: {
703-
* // jadams: 1
704-
* // }
705-
* // }
706-
* // }
707-
* // },
708-
* // ...
709-
* // ]
695+
* if (err.name === 'PartialFailureError') {
696+
* // err.errors[].code = 'Response code'
697+
* // err.errors[].message = 'Error message'
698+
* // err.errors[].entry = The original entry
699+
* }
700+
* }
710701
* };
711702
*
712703
* var entries = [
@@ -769,8 +760,9 @@ Table.prototype.insert = function(entries, callback) {
769760
* deleted.
770761
* @param {function} callback - The callback function.
771762
* @param {?error} callback.err - An error returned while making this request.
772-
* @param {object[]} callback.mutationErrors - A status object for each failed
773-
* mutation.
763+
* @param {object[]} callback.err.errors - If present, these represent partial
764+
* failures. It's possible for part of your request to be completed
765+
* successfully, while the other part was not.
774766
*
775767
* @example
776768
* //-

packages/bigtable/system-test/bigtable.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,7 @@ describe('Bigtable', function() {
405405
}
406406
}];
407407

408-
TABLE.insert(rows, function(err, insertErrors) {
409-
assert.ifError(err);
410-
assert.strictEqual(insertErrors.length, 0);
411-
done();
412-
});
408+
TABLE.insert(rows, done);
413409
});
414410

415411
it('should create an individual row', function(done) {

packages/bigtable/test/table.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -976,13 +976,20 @@ describe('Bigtable/Table', function() {
976976
};
977977
});
978978

979-
it('should populate the mutationErrors array', function(done) {
979+
it('should return a PartialFailureError', function(done) {
980980
table.mutate(entries, function(err, mutationErrors) {
981-
assert.ifError(err);
982-
assert.strictEqual(mutationErrors[0], parsedStatuses[0]);
983-
assert.strictEqual(mutationErrors[0].entry, entries[0]);
984-
assert.strictEqual(mutationErrors[1], parsedStatuses[1]);
985-
assert.strictEqual(mutationErrors[1].entry, entries[1]);
981+
assert.strictEqual(err.name, 'PartialFailureError');
982+
983+
assert.deepEqual(err.errors, [
984+
extend({
985+
entry: entries[0]
986+
}, parsedStatuses[0]),
987+
988+
extend({
989+
entry: entries[1]
990+
}, parsedStatuses[1])
991+
]);
992+
986993
done();
987994
});
988995
});
@@ -1039,14 +1046,6 @@ describe('Bigtable/Table', function() {
10391046
};
10401047
});
10411048

1042-
it('should return an empty array to the callback', function(done) {
1043-
table.mutate(entries, function(err, mutateErrors) {
1044-
assert.ifError(err);
1045-
assert.strictEqual(mutateErrors.length, 0);
1046-
done();
1047-
});
1048-
});
1049-
10501049
it('should emit the appropriate stream events', function(done) {
10511050
var emitter = table.mutate(entries);
10521051

0 commit comments

Comments
 (0)