Skip to content

Commit 46bdc88

Browse files
authored
SNOW-859548 Refactor runTests to runDBTest (#869)
1 parent b00b530 commit 46bdc88

14 files changed

+82
-84
lines changed

arrow_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func TestArrowFloatPrecision(t *testing.T) {
348348
}
349349

350350
func TestArrowTimePrecision(t *testing.T) {
351-
runTests(t, dsn, func(dbt *DBTest) {
351+
runDBTest(t, func(dbt *DBTest) {
352352
dbt.mustExec("CREATE TABLE t (col5 TIME(5), col6 TIME(6), col7 TIME(7), col8 TIME(8));")
353353
defer dbt.mustExec("DROP TABLE IF EXISTS t")
354354
dbt.mustExec("INSERT INTO t VALUES ('23:59:59.99999', '23:59:59.999999', '23:59:59.9999999', '23:59:59.99999999');")
@@ -437,7 +437,7 @@ func TestArrowTimePrecision(t *testing.T) {
437437
}
438438

439439
func TestArrowVariousTypes(t *testing.T) {
440-
runTests(t, dsn, func(dbt *DBTest) {
440+
runDBTest(t, func(dbt *DBTest) {
441441
rows := dbt.mustQueryContext(
442442
WithHigherPrecision(context.Background()), selectVariousTypes)
443443
defer rows.Close()

async_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestAsyncMode(t *testing.T) {
1616
var idx int
1717
var v string
1818

19-
runTests(t, dsn, func(dbt *DBTest) {
19+
runDBTest(t, func(dbt *DBTest) {
2020
rows := dbt.mustQueryContext(ctx, fmt.Sprintf(selectRandomGenerator, numrows))
2121
defer rows.Close()
2222

@@ -55,7 +55,7 @@ func TestAsyncModeMultiStatement(t *testing.T) {
5555
"select 2;\n" +
5656
"rollback;"
5757

58-
runTests(t, dsn, func(dbt *DBTest) {
58+
runDBTest(t, func(dbt *DBTest) {
5959
dbt.mustExec("drop table if exists test_multi_statement_async")
6060
dbt.mustExec(`create or replace table test_multi_statement_async(
6161
c1 number, c2 string) as select 10, 'z'`)
@@ -77,15 +77,15 @@ func TestAsyncModeCancel(t *testing.T) {
7777
ctx := WithAsyncMode(withCancelCtx)
7878
numrows := 100000
7979

80-
runTests(t, dsn, func(dbt *DBTest) {
80+
runDBTest(t, func(dbt *DBTest) {
8181
dbt.mustQueryContext(ctx, fmt.Sprintf(selectRandomGenerator, numrows))
8282
cancel()
8383
})
8484
}
8585

8686
func TestAsyncQueryFail(t *testing.T) {
8787
ctx := WithAsyncMode(context.Background())
88-
runTests(t, dsn, func(dbt *DBTest) {
88+
runDBTest(t, func(dbt *DBTest) {
8989
rows := dbt.mustQueryContext(ctx, "selectt 1")
9090
defer rows.Close()
9191

@@ -108,7 +108,7 @@ func TestMultipleAsyncQueries(t *testing.T) {
108108

109109
db := openDB(t)
110110

111-
runTests(t, dsn, func(dbt *DBTest) {
111+
runDBTest(t, func(dbt *DBTest) {
112112
rows1, err := db.QueryContext(ctx, fmt.Sprintf("select distinct '%v' from table (generator(timelimit=>%v))", s1, 30))
113113
if err != nil {
114114
t.Fatalf("can't read rows1: %v", err)

bindings_test.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737
)
3838

3939
func TestBindingFloat64(t *testing.T) {
40-
runTests(t, dsn, func(dbt *DBTest) {
40+
runDBTest(t, func(dbt *DBTest) {
4141
types := [2]string{"FLOAT", "DOUBLE"}
4242
expected := 42.23
4343
var out float64
@@ -63,7 +63,7 @@ func TestBindingFloat64(t *testing.T) {
6363
// TestBindingUint64 tests uint64 binding. Should fail as unit64 is not a
6464
// supported binding value by Go's sql package.
6565
func TestBindingUint64(t *testing.T) {
66-
runTests(t, dsn, func(dbt *DBTest) {
66+
runDBTest(t, func(dbt *DBTest) {
6767
types := []string{"INTEGER"}
6868
expected := uint64(18446744073709551615)
6969
for _, v := range types {
@@ -80,7 +80,7 @@ func TestBindingUint64(t *testing.T) {
8080

8181
func TestBindingDateTimeTimestamp(t *testing.T) {
8282
createDSN(PSTLocation)
83-
runTests(t, dsn, func(dbt *DBTest) {
83+
runDBTest(t, func(dbt *DBTest) {
8484
expected := time.Now()
8585
dbt.mustExec(
8686
"CREATE OR REPLACE TABLE tztest (id int, ntz timestamp_ntz, ltz timestamp_ltz, dt date, tm time)")
@@ -150,7 +150,7 @@ func TestBindingDateTimeTimestamp(t *testing.T) {
150150
}
151151

152152
func TestBindingBinary(t *testing.T) {
153-
runTests(t, dsn, func(dbt *DBTest) {
153+
runDBTest(t, func(dbt *DBTest) {
154154
dbt.mustExec("CREATE OR REPLACE TABLE bintest (id int, b binary)")
155155
var b = []byte{0x01, 0x02, 0x03}
156156
dbt.mustExec("INSERT INTO bintest(id,b) VALUES(1, ?)", DataTypeBinary, b)
@@ -172,7 +172,7 @@ func TestBindingBinary(t *testing.T) {
172172
}
173173

174174
func TestBindingTimestampTZ(t *testing.T) {
175-
runTests(t, dsn, func(dbt *DBTest) {
175+
runDBTest(t, func(dbt *DBTest) {
176176
expected := time.Now()
177177
dbt.mustExec("CREATE OR REPLACE TABLE tztest (id int, tz timestamp_tz)")
178178
stmt, err := dbt.prepare("INSERT INTO tztest(id,tz) VALUES(1, ?)")
@@ -201,7 +201,7 @@ func TestBindingTimestampTZ(t *testing.T) {
201201

202202
// SNOW-755844: Test the use of a pointer *time.Time type in user-defined structures to perform updates/inserts
203203
func TestBindingTimePtrInStruct(t *testing.T) {
204-
runTests(t, dsn, func(dbt *DBTest) {
204+
runDBTest(t, func(dbt *DBTest) {
205205
type timePtrStruct struct {
206206
id *int
207207
timeVal *time.Time
@@ -248,7 +248,7 @@ func TestBindingTimePtrInStruct(t *testing.T) {
248248

249249
// SNOW-755844: Test the use of a time.Time type in user-defined structures to perform updates/inserts
250250
func TestBindingTimeInStruct(t *testing.T) {
251-
runTests(t, dsn, func(dbt *DBTest) {
251+
runDBTest(t, func(dbt *DBTest) {
252252
type timeStruct struct {
253253
id int
254254
timeVal time.Time
@@ -294,7 +294,7 @@ func TestBindingTimeInStruct(t *testing.T) {
294294
}
295295

296296
func TestBindingInterface(t *testing.T) {
297-
runTests(t, dsn, func(dbt *DBTest) {
297+
runDBTest(t, func(dbt *DBTest) {
298298
rows := dbt.mustQueryContext(
299299
WithHigherPrecision(context.Background()), selectVariousTypes)
300300
defer rows.Close()
@@ -321,7 +321,7 @@ func TestBindingInterface(t *testing.T) {
321321
}
322322

323323
func TestBindingInterfaceString(t *testing.T) {
324-
runTests(t, dsn, func(dbt *DBTest) {
324+
runDBTest(t, func(dbt *DBTest) {
325325
rows := dbt.mustQuery(selectVariousTypes)
326326
defer rows.Close()
327327
if !rows.Next() {
@@ -350,7 +350,7 @@ func TestBindingInterfaceString(t *testing.T) {
350350
func TestBulkArrayBindingInterfaceNil(t *testing.T) {
351351
nilArray := make([]any, 1)
352352

353-
runTests(t, dsn, func(dbt *DBTest) {
353+
runDBTest(t, func(dbt *DBTest) {
354354
dbt.mustExec(createTableSQL)
355355
defer dbt.mustExec(deleteTableSQL)
356356

@@ -436,7 +436,7 @@ func TestBulkArrayBindingInterface(t *testing.T) {
436436
int64Array[0] = int64(100)
437437
int64Array[1] = int64(200)
438438

439-
runTests(t, dsn, func(dbt *DBTest) {
439+
runDBTest(t, func(dbt *DBTest) {
440440
dbt.mustExec(createTableSQLBulkArray)
441441
defer dbt.mustExec(deleteTableSQLBulkArray)
442442

@@ -536,7 +536,7 @@ func TestBulkArrayBindingInterfaceDateTimeTimestamp(t *testing.T) {
536536
tmArray[1] = now.Add(8).In(loc)
537537
tmArray[2] = now.Add(9).In(loc)
538538

539-
runTests(t, dsn, func(dbt *DBTest) {
539+
runDBTest(t, func(dbt *DBTest) {
540540
dbt.mustExec(createTableSQLBulkArrayDateTimeTimestamp)
541541
defer dbt.mustExec(deleteTableSQLBulkArrayDateTimeTimestamp)
542542

@@ -638,7 +638,7 @@ func testBindingArray(t *testing.T, bulk bool) {
638638
dtArray := []time.Time{now.Add(9), now.Add(10), now.Add(11)}
639639
tmArray := []time.Time{now.Add(12), now.Add(13), now.Add(14)}
640640

641-
runTests(t, dsn, func(dbt *DBTest) {
641+
runDBTest(t, func(dbt *DBTest) {
642642
dbt.mustExec(createTableSQL)
643643
defer dbt.mustExec(deleteTableSQL)
644644
if bulk {
@@ -706,7 +706,7 @@ func testBindingArray(t *testing.T, bulk bool) {
706706
}
707707

708708
func TestBulkArrayBinding(t *testing.T) {
709-
runTests(t, dsn, func(dbt *DBTest) {
709+
runDBTest(t, func(dbt *DBTest) {
710710
dbt.mustExec(fmt.Sprintf("create or replace table %v (c1 integer, c2 string)", dbname))
711711
numRows := 100000
712712
intArr := make([]int, numRows)
@@ -751,7 +751,7 @@ func TestBulkArrayMultiPartBinding(t *testing.T) {
751751
tempTableName := fmt.Sprintf("test_table_%v", randomString(5))
752752
ctx := context.Background()
753753

754-
runTests(t, dsn, func(dbt *DBTest) {
754+
runDBTest(t, func(dbt *DBTest) {
755755
dbt.mustExec(fmt.Sprintf("CREATE TABLE %s (C VARCHAR(64) NOT NULL)", tempTableName))
756756
defer dbt.mustExec("drop table " + tempTableName)
757757

@@ -784,7 +784,7 @@ func TestBulkArrayMultiPartBinding(t *testing.T) {
784784
}
785785

786786
func TestBulkArrayMultiPartBindingInt(t *testing.T) {
787-
runTests(t, dsn, func(dbt *DBTest) {
787+
runDBTest(t, func(dbt *DBTest) {
788788
dbt.mustExec("create or replace table binding_test (c1 integer)")
789789
startNum := 1000000
790790
endNum := 3000000
@@ -819,7 +819,7 @@ func TestBulkArrayMultiPartBindingInt(t *testing.T) {
819819
}
820820

821821
func TestBulkArrayMultiPartBindingWithNull(t *testing.T) {
822-
runTests(t, dsn, func(dbt *DBTest) {
822+
runDBTest(t, func(dbt *DBTest) {
823823
dbt.mustExec("create or replace table binding_test (c1 integer, c2 string)")
824824
startNum := 1000000
825825
endNum := 2000000
@@ -911,7 +911,7 @@ func TestFunctionParameters(t *testing.T) {
911911
{"timestamp_tzAndTimeResultInNotNull", "timestamp_tz", time.Now(), false},
912912
}
913913

914-
runTests(t, dsn, func(dbt *DBTest) {
914+
runDBTest(t, func(dbt *DBTest) {
915915
for _, tc := range testcases {
916916
t.Run(tc.testDesc, func(t *testing.T) {
917917
query := fmt.Sprintf(`
@@ -997,7 +997,7 @@ func TestVariousBindingModes(t *testing.T) {
997997
},
998998
}
999999

1000-
runTests(t, dsn, func(dbt *DBTest) {
1000+
runDBTest(t, func(dbt *DBTest) {
10011001
for _, tc := range testcases {
10021002
for _, bindingMode := range bindingModes {
10031003
t.Run(tc.testDesc+" "+bindingMode.param, func(t *testing.T) {

chunk_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ func TestWithStreamDownloader(t *testing.T) {
374374
var idx int
375375
var v string
376376

377-
runTests(t, dsn, func(dbt *DBTest) {
377+
runDBTest(t, func(dbt *DBTest) {
378378
dbt.mustExec(forceJSON)
379379
rows := dbt.mustQueryContext(ctx, fmt.Sprintf(selectRandomGenerator, numrows))
380380
defer rows.Close()

0 commit comments

Comments
 (0)