Skip to content

Commit 3715c3f

Browse files
committed
added TestZeroDialTimeout
1 parent 05725c6 commit 3715c3f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

connection_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ package ydb_test
55

66
import (
77
"context"
8+
"errors"
89
"fmt"
10+
"testing"
11+
"time"
12+
13+
"github.com/stretchr/testify/require"
14+
grpcCodes "google.golang.org/grpc/codes"
915

1016
"github.com/ydb-platform/ydb-go-sdk/v3"
1117
"github.com/ydb-platform/ydb-go-sdk/v3/balancers"
@@ -40,3 +46,18 @@ func ExampleOpen_advanced() {
4046
defer db.Close(ctx) // cleanup resources
4147
fmt.Printf("connected to %s, database '%s'", db.Endpoint(), db.Name())
4248
}
49+
50+
func TestZeroDialTimeout(t *testing.T) {
51+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
52+
defer cancel()
53+
54+
db, err := ydb.Open(
55+
ctx,
56+
"grpc://non-existent.com:2135/some",
57+
ydb.WithDialTimeout(0),
58+
)
59+
60+
require.Error(t, err)
61+
require.Nil(t, db)
62+
require.True(t, errors.Is(err, context.DeadlineExceeded) || ydb.IsTransportError(err, grpcCodes.DeadlineExceeded))
63+
}

0 commit comments

Comments
 (0)