Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion aborted_transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ func TestCommitAborted(t *testing.T) {
if err != nil {
t.Fatalf("begin failed: %v", err)
}
if _, err := tx.ExecContext(ctx, testutil.UpdateBarSetFoo); err != nil {
t.Fatal(err)
}
server.TestSpanner.PutExecutionTime(testutil.MethodCommitTransaction, testutil.SimulatedExecutionTime{
Errors: []error{status.Error(codes.Aborted, "Aborted")},
})
Expand All @@ -51,7 +54,7 @@ func TestCommitAborted(t *testing.T) {
reqs := server.TestSpanner.DrainRequestsFromServer()
commitReqs := testutil.RequestsOfType(reqs, reflect.TypeOf(&sppb.CommitRequest{}))
if g, w := len(commitReqs), 2; g != w {
t.Fatalf("commit request count mismatch\nGot: %v\nWant: %v", g, w)
t.Fatalf("commit request count mismatch\n Got: %v\nWant: %v", g, w)
}

// Verify that the db is still usable.
Expand Down Expand Up @@ -117,6 +120,9 @@ func TestCommitAbortedWithInternalRetriesDisabled(t *testing.T) {
if err != nil {
t.Fatalf("begin failed: %v", err)
}
if _, err := tx.ExecContext(ctx, testutil.UpdateBarSetFoo); err != nil {
t.Fatal(err)
}
server.TestSpanner.PutExecutionTime(testutil.MethodCommitTransaction, testutil.SimulatedExecutionTime{
Errors: []error{status.Error(codes.Aborted, "Aborted")},
})
Expand Down
6 changes: 3 additions & 3 deletions client_side_statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestStatementExecutor_StartBatchDdl(t *testing.T) {
}

// Starting a DDL batch while the connection is in a transaction is not allowed.
c.tx = &readWriteTransaction{}
c.tx = &delegatingTransaction{conn: c, ctx: ctx}
if _, err := c.ExecContext(ctx, "start batch ddl", []driver.NamedValue{}); spanner.ErrCode(err) != codes.FailedPrecondition {
t.Fatalf("error mismatch for starting a DDL batch while in a transaction\nGot: %v\nWant: %v", spanner.ErrCode(err), codes.FailedPrecondition)
}
Expand Down Expand Up @@ -102,13 +102,13 @@ func TestStatementExecutor_StartBatchDml(t *testing.T) {
}

// Starting a DML batch while the connection is in a read-only transaction is not allowed.
c.tx = &readOnlyTransaction{logger: noopLogger}
c.tx = &delegatingTransaction{conn: c, contextTransaction: &readOnlyTransaction{logger: noopLogger}}
if _, err := c.ExecContext(ctx, "start batch dml", []driver.NamedValue{}); spanner.ErrCode(err) != codes.FailedPrecondition {
t.Fatalf("error mismatch for starting a DML batch while in a read-only transaction\nGot: %v\nWant: %v", spanner.ErrCode(err), codes.FailedPrecondition)
}

// Starting a DML batch while the connection is in a read/write transaction is allowed.
c.tx = &readWriteTransaction{logger: noopLogger}
c.tx = &delegatingTransaction{conn: c, contextTransaction: &readWriteTransaction{logger: noopLogger}}
if _, err := c.ExecContext(ctx, "start batch dml", []driver.NamedValue{}); err != nil {
t.Fatalf("could not start a DML batch while in a read/write transaction: %v", err)
}
Expand Down
Loading
Loading