Skip to content

Commit

Permalink
Add an end-to-end test.
Browse files Browse the repository at this point in the history
  • Loading branch information
hengfengli committed Jul 16, 2020
1 parent 052f73c commit 987a8ab
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion spanner/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,8 @@ func TestClient_WithGRPCConnectionPoolAndNumChannels_Misconfigured(t *testing.T)
}
}

func TestClient_WithCallOptions(t *testing.T) {
func TestClient_CallOptions(t *testing.T) {
t.Parallel()
co := &vkit.CallOptions{
CreateSession: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
Expand Down Expand Up @@ -1799,6 +1800,39 @@ func TestClient_WithCallOptions(t *testing.T) {
}
}

func TestClient_QueryWithCallOptions(t *testing.T) {
t.Parallel()
co := &vkit.CallOptions{
ExecuteSql: []gax.CallOption{
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.DeadlineExceeded,
}, gax.Backoff{
Initial: 200 * time.Millisecond,
Max: 30000 * time.Millisecond,
Multiplier: 1.25,
})
}),
},
}
server, client, teardown := setupMockedTestServerWithConfig(t, ClientConfig{CallOptions: co})
server.TestSpanner.PutExecutionTime(MethodExecuteSql, SimulatedExecutionTime{
Errors: []error{status.Error(codes.DeadlineExceeded, "Deadline exceeded")},
})
defer teardown()
ctx := context.Background()
_, err := client.ReadWriteTransaction(ctx, func(ctx context.Context, tx *ReadWriteTransaction) error {
_, err := tx.Update(ctx, Statement{SQL: UpdateBarSetFoo})
if err != nil {
return err
}
return nil
})
if err != nil {
t.Fatal(err)
}
}

func TestBatchReadOnlyTransaction_QueryOptions(t *testing.T) {
ctx := context.Background()
qo := QueryOptions{Options: &sppb.ExecuteSqlRequest_QueryOptions{OptimizerVersion: "1"}}
Expand Down

0 comments on commit 987a8ab

Please sign in to comment.