@@ -3,23 +3,24 @@ package isolation
33import (
44 "database/sql"
55 "database/sql/driver"
6- "fmt"
76 "testing"
87
98 "github.com/stretchr/testify/require"
10- "google.golang.org/protobuf/proto"
119
10+ "github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"
1211 "github.com/ydb-platform/ydb-go-sdk/v3/table"
1312)
1413
1514func TestToYDB (t * testing.T ) {
1615 for _ , tt := range []struct {
16+ name string
1717 txOptions driver.TxOptions
1818 txControl table.TxOption
1919 err bool
2020 }{
2121 // read-write
2222 {
23+ name : xtest .CurrentFileLine (),
2324 txOptions : driver.TxOptions {
2425 Isolation : driver .IsolationLevel (sql .LevelDefault ),
2526 ReadOnly : false ,
@@ -28,48 +29,56 @@ func TestToYDB(t *testing.T) {
2829 err : false ,
2930 },
3031 {
32+ name : xtest .CurrentFileLine (),
3133 txOptions : driver.TxOptions {
3234 Isolation : driver .IsolationLevel (sql .LevelReadUncommitted ),
3335 ReadOnly : false ,
3436 },
3537 err : true ,
3638 },
3739 {
40+ name : xtest .CurrentFileLine (),
3841 txOptions : driver.TxOptions {
3942 Isolation : driver .IsolationLevel (sql .LevelReadCommitted ),
4043 ReadOnly : false ,
4144 },
4245 err : true ,
4346 },
4447 {
48+ name : xtest .CurrentFileLine (),
4549 txOptions : driver.TxOptions {
4650 Isolation : driver .IsolationLevel (sql .LevelWriteCommitted ),
4751 ReadOnly : false ,
4852 },
4953 err : true ,
5054 },
5155 {
56+ name : xtest .CurrentFileLine (),
5257 txOptions : driver.TxOptions {
5358 Isolation : driver .IsolationLevel (sql .LevelRepeatableRead ),
5459 ReadOnly : false ,
5560 },
5661 err : true ,
5762 },
5863 {
64+ name : xtest .CurrentFileLine (),
5965 txOptions : driver.TxOptions {
6066 Isolation : driver .IsolationLevel (sql .LevelSnapshot ),
6167 ReadOnly : false ,
6268 },
6369 err : true ,
6470 },
6571 {
72+ name : xtest .CurrentFileLine (),
6673 txOptions : driver.TxOptions {
6774 Isolation : driver .IsolationLevel (sql .LevelSerializable ),
6875 ReadOnly : false ,
6976 },
70- err : true ,
77+ txControl : table .WithSerializableReadWrite (),
78+ err : false ,
7179 },
7280 {
81+ name : xtest .CurrentFileLine (),
7382 txOptions : driver.TxOptions {
7483 Isolation : driver .IsolationLevel (sql .LevelLinearizable ),
7584 ReadOnly : false ,
@@ -79,41 +88,47 @@ func TestToYDB(t *testing.T) {
7988
8089 // read-only
8190 {
91+ name : xtest .CurrentFileLine (),
8292 txOptions : driver.TxOptions {
8393 Isolation : driver .IsolationLevel (sql .LevelDefault ),
8494 ReadOnly : true ,
8595 },
8696 err : true ,
8797 },
8898 {
99+ name : xtest .CurrentFileLine (),
89100 txOptions : driver.TxOptions {
90101 Isolation : driver .IsolationLevel (sql .LevelReadUncommitted ),
91102 ReadOnly : true ,
92103 },
93104 err : true ,
94105 },
95106 {
107+ name : xtest .CurrentFileLine (),
96108 txOptions : driver.TxOptions {
97109 Isolation : driver .IsolationLevel (sql .LevelReadCommitted ),
98110 ReadOnly : true ,
99111 },
100112 err : true ,
101113 },
102114 {
115+ name : xtest .CurrentFileLine (),
103116 txOptions : driver.TxOptions {
104117 Isolation : driver .IsolationLevel (sql .LevelWriteCommitted ),
105118 ReadOnly : true ,
106119 },
107120 err : true ,
108121 },
109122 {
123+ name : xtest .CurrentFileLine (),
110124 txOptions : driver.TxOptions {
111125 Isolation : driver .IsolationLevel (sql .LevelRepeatableRead ),
112126 ReadOnly : true ,
113127 },
114128 err : true ,
115129 },
116130 {
131+ name : xtest .CurrentFileLine (),
117132 txOptions : driver.TxOptions {
118133 Isolation : driver .IsolationLevel (sql .LevelSnapshot ),
119134 ReadOnly : true ,
@@ -122,27 +137,27 @@ func TestToYDB(t *testing.T) {
122137 err : false ,
123138 },
124139 {
140+ name : xtest .CurrentFileLine (),
125141 txOptions : driver.TxOptions {
126142 Isolation : driver .IsolationLevel (sql .LevelSerializable ),
127143 ReadOnly : true ,
128144 },
129145 err : true ,
130146 },
131147 {
148+ name : xtest .CurrentFileLine (),
132149 txOptions : driver.TxOptions {
133150 Isolation : driver .IsolationLevel (sql .LevelLinearizable ),
134151 ReadOnly : true ,
135152 },
136153 err : true ,
137154 },
138155 } {
139- t .Run (fmt . Sprintf ( "%+v" , tt .txOptions ) , func (t * testing.T ) {
156+ t .Run (tt .name , func (t * testing.T ) {
140157 toYDB , err := ToYDB (tt .txOptions )
141158 if ! tt .err {
142159 require .NoError (t , err )
143- if ! proto .Equal (table .TxSettings (tt .txControl ).Settings (), table .TxSettings (toYDB ).Settings ()) {
144- t .Errorf ("%+v != %+v" , toYDB , tt .txControl )
145- }
160+ require .Equal (t , table .TxSettings (tt .txControl ).Settings (), table .TxSettings (toYDB ).Settings ())
146161 } else {
147162 require .Error (t , err )
148163 }
0 commit comments