-
Notifications
You must be signed in to change notification settings - Fork 77
/
driver_string_test.go
72 lines (68 loc) · 2.58 KB
/
driver_string_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package ydb
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/ydb-platform/ydb-go-sdk/v3/config"
"github.com/ydb-platform/ydb-go-sdk/v3/credentials"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"
)
func TestDriver_String(t *testing.T) {
for _, tt := range []struct {
name string
d *Driver
s string
}{
{
name: xtest.CurrentFileLine(),
d: &Driver{config: config.New(
config.WithEndpoint("localhost"),
config.WithDatabase("local"),
config.WithSecure(false),
)},
s: `Driver{Endpoint:"localhost",Database:"local",Secure:false,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:80)"}}`, //nolint:lll
},
{
name: xtest.CurrentFileLine(),
d: &Driver{config: config.New(
config.WithEndpoint("localhost"),
config.WithDatabase("local"),
config.WithSecure(true),
)},
s: `Driver{Endpoint:"localhost",Database:"local",Secure:true,Credentials:Anonymous{From:"github.com/ydb-platform/ydb-go-sdk/v3/config.defaultConfig(defaults.go:80)"}}`, //nolint:lll
},
{
name: xtest.CurrentFileLine(),
d: &Driver{config: config.New(
config.WithEndpoint("localhost"),
config.WithDatabase("local"),
config.WithSecure(false),
config.WithCredentials(credentials.NewAnonymousCredentials(credentials.WithSourceInfo(t.Name()))),
)},
s: `Driver{Endpoint:"localhost",Database:"local",Secure:false,Credentials:Anonymous{From:"TestDriver_String"}}`, //nolint:lll
},
{
name: xtest.CurrentFileLine(),
d: &Driver{config: config.New(
config.WithEndpoint("localhost"),
config.WithDatabase("local"),
config.WithSecure(true),
config.WithCredentials(credentials.NewStaticCredentials("user", "password", "")),
)},
s: `Driver{Endpoint:"localhost",Database:"local",Secure:true,Credentials:Static{User:"user",Password:"pas***rd",Token:"****(CRC-32c: 00000000)",From:"github.com/ydb-platform/ydb-go-sdk/v3/credentials.NewStaticCredentials(credentials.go:35)"}}`, //nolint:lll
},
{
name: xtest.CurrentFileLine(),
d: &Driver{config: config.New(
config.WithEndpoint("localhost"),
config.WithDatabase("local"),
config.WithSecure(true),
config.WithCredentials(credentials.NewAccessTokenCredentials("AUTH_TOKEN")),
)},
s: `Driver{Endpoint:"localhost",Database:"local",Secure:true,Credentials:AccessToken{Token:"****(CRC-32c: 9F26E847)",From:"github.com/ydb-platform/ydb-go-sdk/v3/credentials.NewAccessTokenCredentials(credentials.go:20)"}}`, //nolint:lll
},
} {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.s, tt.d.String())
})
}
}