|
1 | 1 | package sugar |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | 4 | "testing" |
| 5 | + |
| 6 | + "github.com/ydb-platform/ydb-go-sdk/v3/config" |
| 7 | + "github.com/ydb-platform/ydb-go-sdk/v3/internal/dsn" |
6 | 8 | ) |
7 | 9 |
|
8 | 10 | func TestDSN(t *testing.T) { |
@@ -39,9 +41,23 @@ func TestDSN(t *testing.T) { |
39 | 41 | }, |
40 | 42 | } { |
41 | 43 | t.Run(test.dsn, func(t *testing.T) { |
42 | | - dsn := DSN(test.endpoint, test.database, test.secure) |
43 | | - if dsn != test.dsn { |
44 | | - t.Fatal(fmt.Sprintf("Unexpected result: %s, exp: %s", dsn, test.dsn)) |
| 44 | + s := DSN(test.endpoint, test.database, test.secure) |
| 45 | + if s != test.dsn { |
| 46 | + t.Fatalf("Unexpected result: %s, exp: %s", s, test.dsn) |
| 47 | + } |
| 48 | + opts, err := dsn.Parse(s) |
| 49 | + if err != nil { |
| 50 | + t.Fatalf("") |
| 51 | + } |
| 52 | + config := config.New(opts...) |
| 53 | + if config.Endpoint() != test.endpoint { |
| 54 | + t.Fatalf("Unexpected endpoint: %s, exp: %s", config.Endpoint(), test.endpoint) |
| 55 | + } |
| 56 | + if config.Database() != test.database { |
| 57 | + t.Fatalf("Unexpected database: %s, exp: %s", config.Database(), test.database) |
| 58 | + } |
| 59 | + if config.Secure() != test.secure { |
| 60 | + t.Fatalf("Unexpected secure flag: %v, exp: %v", config.Secure(), test.secure) |
45 | 61 | } |
46 | 62 | }) |
47 | 63 | } |
|
0 commit comments