88
99 "github.com/ydb-platform/ydb-go-sdk/v3/config"
1010 "github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
11- "github.com/ydb-platform/ydb-go-sdk/v3/internal/table/conn"
11+ querySql "github.com/ydb-platform/ydb-go-sdk/v3/internal/query/conn"
12+ tableSql "github.com/ydb-platform/ydb-go-sdk/v3/internal/table/conn"
1213 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql"
1314)
1415
@@ -25,6 +26,12 @@ func TestParse(t *testing.T) {
2526
2627 return c
2728 }
29+ newTableConn := func (opts ... tableSql.Option ) * tableSql.Conn {
30+ return tableSql .New (context .Background (), nil , nil , opts ... )
31+ }
32+ newQueryConn := func (opts ... querySql.Option ) * querySql.Conn {
33+ return querySql .New (context .Background (), nil , nil , opts ... )
34+ }
2835 compareConfigs := func (t * testing.T , lhs , rhs * config.Config ) {
2936 require .Equal (t , lhs .Secure (), rhs .Secure ())
3037 require .Equal (t , lhs .Endpoint (), rhs .Endpoint ())
@@ -36,19 +43,6 @@ func TestParse(t *testing.T) {
3643 connectorOpts []xsql.Option
3744 err error
3845 }{
39- {
40- dsn : "grpc://localhost:2135/local?go_fake_tx=scripting,scheme" ,
41- opts : []config.Option {
42- config .WithSecure (false ),
43- config .WithEndpoint ("localhost:2135" ),
44- config .WithDatabase ("/local" ),
45- },
46- connectorOpts : []xsql.Option {
47- xsql .WithFakeTx (conn .ScriptingQueryMode ),
48- xsql .WithFakeTx (conn .SchemeQueryMode ),
49- },
50- err : nil ,
51- },
5246 {
5347 dsn : "grpc://localhost:2135/local" ,
5448 opts : []config.Option {
@@ -77,7 +71,7 @@ func TestParse(t *testing.T) {
7771 config .WithDatabase ("/local" ),
7872 },
7973 connectorOpts : []xsql.Option {
80- xsql .WithDefaultQueryMode (conn .ScriptingQueryMode ),
74+ xsql .WithDefaultQueryMode (tableSql .ScriptingQueryMode ),
8175 },
8276 err : nil ,
8377 },
@@ -89,7 +83,7 @@ func TestParse(t *testing.T) {
8983 config .WithDatabase ("/local" ),
9084 },
9185 connectorOpts : []xsql.Option {
92- xsql .WithDefaultQueryMode (conn .ScriptingQueryMode ),
86+ xsql .WithDefaultQueryMode (tableSql .ScriptingQueryMode ),
9387 xsql .WithQueryBind (bind .TablePathPrefix ("path/to/tables" )),
9488 },
9589 err : nil ,
@@ -102,7 +96,7 @@ func TestParse(t *testing.T) {
10296 config .WithDatabase ("/local" ),
10397 },
10498 connectorOpts : []xsql.Option {
105- xsql .WithDefaultQueryMode (conn .ScriptingQueryMode ),
99+ xsql .WithDefaultQueryMode (tableSql .ScriptingQueryMode ),
106100 xsql .WithQueryBind (bind .TablePathPrefix ("path/to/tables" )),
107101 xsql .WithQueryBind (bind.NumericArgs {}),
108102 },
@@ -116,7 +110,7 @@ func TestParse(t *testing.T) {
116110 config .WithDatabase ("/local" ),
117111 },
118112 connectorOpts : []xsql.Option {
119- xsql .WithDefaultQueryMode (conn .ScriptingQueryMode ),
113+ xsql .WithDefaultQueryMode (tableSql .ScriptingQueryMode ),
120114 xsql .WithQueryBind (bind .TablePathPrefix ("path/to/tables" )),
121115 xsql .WithQueryBind (bind.PositionalArgs {}),
122116 },
@@ -130,7 +124,7 @@ func TestParse(t *testing.T) {
130124 config .WithDatabase ("/local" ),
131125 },
132126 connectorOpts : []xsql.Option {
133- xsql .WithDefaultQueryMode (conn .ScriptingQueryMode ),
127+ xsql .WithDefaultQueryMode (tableSql .ScriptingQueryMode ),
134128 xsql .WithQueryBind (bind .TablePathPrefix ("path/to/tables" )),
135129 xsql .WithQueryBind (bind.AutoDeclare {}),
136130 },
@@ -144,7 +138,7 @@ func TestParse(t *testing.T) {
144138 config .WithDatabase ("/local" ),
145139 },
146140 connectorOpts : []xsql.Option {
147- xsql .WithDefaultQueryMode (conn .ScriptingQueryMode ),
141+ xsql .WithDefaultQueryMode (tableSql .ScriptingQueryMode ),
148142 xsql .WithQueryBind (bind .TablePathPrefix ("path/to/tables" )),
149143 },
150144 err : nil ,
@@ -157,13 +151,26 @@ func TestParse(t *testing.T) {
157151 config .WithDatabase ("/local" ),
158152 },
159153 connectorOpts : []xsql.Option {
160- xsql .WithDefaultQueryMode (conn .ScriptingQueryMode ),
154+ xsql .WithDefaultQueryMode (tableSql .ScriptingQueryMode ),
161155 xsql .WithQueryBind (bind .TablePathPrefix ("path/to/tables" )),
162156 xsql .WithQueryBind (bind.PositionalArgs {}),
163157 xsql .WithQueryBind (bind.AutoDeclare {}),
164158 },
165159 err : nil ,
166160 },
161+ {
162+ dsn : "grpc://localhost:2135/local?go_fake_tx=scripting,scheme" ,
163+ opts : []config.Option {
164+ config .WithSecure (false ),
165+ config .WithEndpoint ("localhost:2135" ),
166+ config .WithDatabase ("/local" ),
167+ },
168+ connectorOpts : []xsql.Option {
169+ xsql .WithFakeTx (tableSql .ScriptingQueryMode ),
170+ xsql .WithFakeTx (tableSql .SchemeQueryMode ),
171+ },
172+ err : nil ,
173+ },
167174 } {
168175 t .Run ("" , func (t * testing.T ) {
169176 opts , err := parseConnectionString (tt .dsn )
@@ -173,7 +180,20 @@ func TestParse(t *testing.T) {
173180 require .NoError (t , err )
174181 d , err := newConnectionFromOptions (context .Background (), opts ... )
175182 require .NoError (t , err )
176- require .Equal (t , newConnector (tt .connectorOpts ... ), newConnector (d .databaseSQLOptions ... ))
183+ exp := newConnector (tt .connectorOpts ... )
184+ act := newConnector (d .databaseSQLOptions ... )
185+ t .Run ("tableOptions" , func (t * testing.T ) {
186+ require .Equal (t , newTableConn (exp .TableOpts ... ), newTableConn (act .TableOpts ... ))
187+ })
188+ t .Run ("queryOptions" , func (t * testing.T ) {
189+ require .Equal (t , newQueryConn (exp .QueryOpts ... ), newQueryConn (act .QueryOpts ... ))
190+ })
191+ exp .TableOpts = nil
192+ exp .QueryOpts = nil
193+ act .TableOpts = nil
194+ act .QueryOpts = nil
195+ require .Equal (t , exp .Bindings (), act .Bindings ())
196+ require .Equal (t , exp , act )
177197 compareConfigs (t , config .New (tt .opts ... ), d .config )
178198 }
179199 })
0 commit comments