From 9a6ca0a6b7ffe954b3fff1b1e74cd607590fee2b Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Thu, 22 Aug 2024 16:42:27 +0300 Subject: [PATCH 1/3] fix(spanner): add missing error checks to tests --- spanner/transaction_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spanner/transaction_test.go b/spanner/transaction_test.go index 94849d608148..365f72e8e162 100644 --- a/spanner/transaction_test.go +++ b/spanner/transaction_test.go @@ -566,6 +566,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) @@ -593,6 +597,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) @@ -654,6 +662,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 }) From dae357015aba3c0de1d5499bbd3906f1c0cbf6b7 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Thu, 22 Aug 2024 16:44:46 +0300 Subject: [PATCH 2/3] fix(spanner): check error before using client in test --- spanner/client_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spanner/client_test.go b/spanner/client_test.go index 20891a5a1519..c43261e2f65e 100644 --- a/spanner/client_test.go +++ b/spanner/client_test.go @@ -4725,10 +4725,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) { From 7e86b9f412945065cffbc8acf1c56e37d0db009d Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Thu, 22 Aug 2024 16:45:28 +0300 Subject: [PATCH 3/3] chore(spanner): remove redundant return-s --- spanner/client_test.go | 1 - spanner/session.go | 1 - 2 files changed, 2 deletions(-) diff --git a/spanner/client_test.go b/spanner/client_test.go index c43261e2f65e..497a2f12dc3a 100644 --- a/spanner/client_test.go +++ b/spanner/client_test.go @@ -3149,7 +3149,6 @@ func TestClient_ReadWriteTransactionConcurrentQueries(t *testing.T) { } rowCount++ } - return } wg.Add(2) go query(&firstTransactionID) diff --git a/spanner/session.go b/spanner/session.go index 3e587095a007..471961abaa6c 100644 --- a/spanner/session.go +++ b/spanner/session.go @@ -762,7 +762,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))