@@ -128,10 +128,12 @@ func TestGoTypeToSnowflake(t *testing.T) {
128
128
{in : nil , tmode : nullType , out : unSupportedType },
129
129
}
130
130
for _ , test := range testcases {
131
- a := goTypeToSnowflake (test .in , test .tmode )
132
- if a != test .out {
133
- t .Errorf ("failed. in: %v, tmode: %v, expected: %v, got: %v" , test .in , test .tmode , test .out , a )
134
- }
131
+ t .Run (fmt .Sprintf ("%v_%v_%v" , test .in , test .out , test .tmode ), func (t * testing.T ) {
132
+ a := goTypeToSnowflake (test .in , test .tmode )
133
+ if a != test .out {
134
+ t .Errorf ("failed. in: %v, tmode: %v, expected: %v, got: %v" , test .in , test .tmode , test .out , a )
135
+ }
136
+ })
135
137
}
136
138
}
137
139
@@ -160,11 +162,13 @@ func TestSnowflakeTypeToGo(t *testing.T) {
160
162
{in : sliceType , scale : 0 , out : reflect .TypeOf ("" )},
161
163
}
162
164
for _ , test := range testcases {
163
- a := snowflakeTypeToGo (test .in , test .scale )
164
- if a != test .out {
165
- t .Errorf ("failed. in: %v, scale: %v, expected: %v, got: %v" ,
166
- test .in , test .scale , test .out , a )
167
- }
165
+ t .Run (fmt .Sprintf ("%v_%v" , test .in , test .out ), func (t * testing.T ) {
166
+ a := snowflakeTypeToGo (test .in , test .scale )
167
+ if a != test .out {
168
+ t .Errorf ("failed. in: %v, scale: %v, expected: %v, got: %v" ,
169
+ test .in , test .scale , test .out , a )
170
+ }
171
+ })
168
172
}
169
173
}
170
174
@@ -263,12 +267,14 @@ func TestStringToValue(t *testing.T) {
263
267
}
264
268
265
269
for _ , tt := range types {
266
- rowType = & execResponseRowType {
267
- Type : tt ,
268
- }
269
- if err = stringToValue (& dest , * rowType , & source , nil ); err == nil {
270
- t .Errorf ("should raise error. type: %v, value:%v" , tt , source )
271
- }
270
+ t .Run (tt , func (t * testing.T ) {
271
+ rowType = & execResponseRowType {
272
+ Type : tt ,
273
+ }
274
+ if err = stringToValue (& dest , * rowType , & source , nil ); err == nil {
275
+ t .Errorf ("should raise error. type: %v, value:%v" , tt , source )
276
+ }
277
+ })
272
278
}
273
279
274
280
sources := []string {
@@ -282,12 +288,14 @@ func TestStringToValue(t *testing.T) {
282
288
283
289
for _ , ss := range sources {
284
290
for _ , tt := range types {
285
- rowType = & execResponseRowType {
286
- Type : tt ,
287
- }
288
- if err = stringToValue (& dest , * rowType , & ss , nil ); err == nil {
289
- t .Errorf ("should raise error. type: %v, value:%v" , tt , source )
290
- }
291
+ t .Run (ss + tt , func (t * testing.T ) {
292
+ rowType = & execResponseRowType {
293
+ Type : tt ,
294
+ }
295
+ if err = stringToValue (& dest , * rowType , & ss , nil ); err == nil {
296
+ t .Errorf ("should raise error. type: %v, value:%v" , tt , source )
297
+ }
298
+ })
291
299
}
292
300
}
293
301
@@ -318,15 +326,17 @@ func TestArrayToString(t *testing.T) {
318
326
{in : driver.NamedValue {Value : & stringArray {"foo" , "bar" , "baz" }}, typ : textType , out : []string {"foo" , "bar" , "baz" }},
319
327
}
320
328
for _ , test := range testcases {
321
- s , a := snowflakeArrayToString (& test .in , false )
322
- if s != test .typ {
323
- t .Errorf ("failed. in: %v, expected: %v, got: %v" , test .in , test .typ , s )
324
- }
325
- for i , v := range a {
326
- if * v != test .out [i ] {
327
- t .Errorf ("failed. in: %v, expected: %v, got: %v" , test .in , test .out [i ], a )
329
+ t .Run (strings .Join (test .out , "_" ), func (t * testing.T ) {
330
+ s , a := snowflakeArrayToString (& test .in , false )
331
+ if s != test .typ {
332
+ t .Errorf ("failed. in: %v, expected: %v, got: %v" , test .in , test .typ , s )
328
333
}
329
- }
334
+ for i , v := range a {
335
+ if * v != test .out [i ] {
336
+ t .Errorf ("failed. in: %v, expected: %v, got: %v" , test .in , test .out [i ], a )
337
+ }
338
+ }
339
+ })
330
340
}
331
341
}
332
342
@@ -1377,12 +1387,14 @@ func TestTimeTypeValueToString(t *testing.T) {
1377
1387
}
1378
1388
1379
1389
for _ , tc := range testcases {
1380
- output , err := timeTypeValueToString (tc .in , tc .tsmode )
1381
- if err != nil {
1382
- t .Error (err )
1383
- }
1384
- if strings .Compare (tc .out , * output ) != 0 {
1385
- t .Errorf ("failed to convert time %v of type %v. expected: %v, received: %v" , tc .in , tc .tsmode , tc .out , * output )
1386
- }
1390
+ t .Run (tc .out , func (t * testing.T ) {
1391
+ output , err := timeTypeValueToString (tc .in , tc .tsmode )
1392
+ if err != nil {
1393
+ t .Error (err )
1394
+ }
1395
+ if strings .Compare (tc .out , * output ) != 0 {
1396
+ t .Errorf ("failed to convert time %v of type %v. expected: %v, received: %v" , tc .in , tc .tsmode , tc .out , * output )
1397
+ }
1398
+ })
1387
1399
}
1388
1400
}
0 commit comments