Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bhshkh committed Jan 15, 2025
1 parent 748fe7f commit b44cbd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions bigtable/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,11 @@ func (t *Table) doApplyBulk(ctx context.Context, entryErrs []*entryErr, headerMD
}
}

var topLevelErr error
defer func() {
populateTopLevelError(entryErrs, topLevelErr)
}()

entries := make([]*btpb.MutateRowsRequest_Entry, len(entryErrs))
for i, entryErr := range entryErrs {
entries[i] = entryErr.Entry
Expand All @@ -1364,8 +1369,7 @@ func (t *Table) doApplyBulk(ctx context.Context, entryErrs []*entryErr, headerMD

stream, err := t.c.client.MutateRows(ctx, req)
if err != nil {
_, topLevelErr := convertToGrpcStatusErr(err)
populateTopLevelError(entryErrs, topLevelErr)
_, topLevelErr = convertToGrpcStatusErr(err)
return err
}

Expand All @@ -1380,12 +1384,10 @@ func (t *Table) doApplyBulk(ctx context.Context, entryErrs []*entryErr, headerMD
}
if err != nil {
*trailerMD = stream.Trailer()
_, topLevelErr := convertToGrpcStatusErr(err)
populateTopLevelError(entryErrs, topLevelErr)
_, topLevelErr = convertToGrpcStatusErr(err)
return err
}

populateTopLevelError(entryErrs, nil)
for _, entry := range res.Entries {
s := entry.Status
if s.Code == int32(codes.OK) {
Expand Down
4 changes: 2 additions & 2 deletions bigtable/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ func TestRetryApplyBulk_IndividualErrorsAndDeadlineExceeded(t *testing.T) {
if !equalErrs(wantErr, err) {
t.Fatalf("deadline exceeded error: got: %v, want: %v", err, wantErr)
}
if errors == nil {
t.Errorf("deadline exceeded errors: got: %v, want: %v", err, []error{wantErr})
if errors != nil {
t.Errorf("deadline exceeded errors: got: %v, want: nil", err)
}
}

Expand Down

0 comments on commit b44cbd0

Please sign in to comment.