Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(spanner): check errors in tests #10738

Merged
merged 5 commits into from
Sep 25, 2024
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
3 changes: 1 addition & 2 deletions spanner/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3144,7 +3144,6 @@ func TestClient_ReadWriteTransactionConcurrentQueries(t *testing.T) {
}
rowCount++
}
return
}
wg.Add(2)
go query(&firstTransactionID)
Expand Down Expand Up @@ -4720,10 +4719,10 @@ func TestClient_EmulatorWithCredentialsFile(t *testing.T) {
"localhost:1234",
opts...,
)
defer client.Close()
if err != nil {
t.Fatalf("Failed to create a client with credentials file when running against an emulator: %v", err)
}
defer client.Close()
}

func TestBatchReadOnlyTransaction_QueryOptions(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion spanner/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,6 @@ func newSessionPool(sc *sessionClient, config SessionPoolConfig) (*sessionPool,
// wait for the session to be created
case <-pool.mayGetMultiplexedSession:
}
return
}()
}
pool.recordStat(context.Background(), MaxAllowedSessionsCount, int64(config.MaxOpened))
Expand Down
12 changes: 12 additions & 0 deletions spanner/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ func TestReadWriteStmtBasedTransactionWithOptions(t *testing.T) {
client,
TransactionOptions{CommitOptions: CommitOptions{ReturnCommitStats: true}},
)
if err != nil {
t.Fatalf("failed to create transaction: %v", err)
}

_, err = f(tx)
if err != nil && status.Code(err) != codes.Aborted {
tx.Rollback(ctx)
Expand Down Expand Up @@ -592,6 +596,10 @@ func TestBatchDML_StatementBased_WithMultipleDML(t *testing.T) {
defer teardown()

tx, err := NewReadWriteStmtBasedTransaction(ctx, client)
if err != nil {
t.Fatalf("failed to create transaction: %v", err)
}

if _, err = tx.Update(ctx, Statement{SQL: UpdateBarSetFoo}); err != nil {
tx.Rollback(ctx)
t.Fatal(err)
Expand Down Expand Up @@ -653,6 +661,10 @@ func TestPriorityInQueryOptions(t *testing.T) {
defer teardown()

tx, err := NewReadWriteStmtBasedTransaction(ctx, client)
if err != nil {
t.Fatalf("failed to create transaction: %v", err)
}

var iter *RowIterator
iter = tx.txReadOnly.Query(ctx, NewStatement("SELECT 1"))
err = iter.Do(func(r *Row) error { return nil })
Expand Down
Loading