1818package mysqlserver
1919
2020import (
21- "context"
2221 "database/sql"
2322 "fmt"
2423 "io"
@@ -41,7 +40,7 @@ import (
4140
4241// TestMultiStmt checks that multiStatements=True and multiStatements=False work properly.
4342func TestMultiStatement (t * testing.T ) {
44- ctx := context . Background ()
43+ ctx := t . Context ()
4544
4645 // connect database with multiStatements=True
4746 db := connectDB (t , vtParams , "multiStatements=True" , "timeout=90s" , "collation=utf8mb4_unicode_ci" )
@@ -68,7 +67,7 @@ func TestMultiStatement(t *testing.T) {
6867
6968// TestLargeComment add large comment in insert stmt and validate the insert process.
7069func TestLargeComment (t * testing.T ) {
71- ctx := context . Background ()
70+ ctx := t . Context ()
7271
7372 conn , err := mysql .Connect (ctx , & vtParams )
7473 require .Nilf (t , err , "unable to connect mysql: %v" , err )
@@ -86,7 +85,7 @@ func TestLargeComment(t *testing.T) {
8685
8786// TestInsertLargerThenGrpcLimit insert blob larger then grpc limit and verify the error.
8887func TestInsertLargerThenGrpcLimit (t * testing.T ) {
89- ctx := context . Background ()
88+ ctx := t . Context ()
9089
9190 conn , err := mysql .Connect (ctx , & vtParams )
9291 require .Nilf (t , err , "unable to connect mysql: %v" , err )
@@ -104,7 +103,7 @@ func TestInsertLargerThenGrpcLimit(t *testing.T) {
104103
105104// TestTimeout executes sleep(5) with query_timeout of 1 second, and verifies the error.
106105func TestTimeout (t * testing.T ) {
107- ctx := context . Background ()
106+ ctx := t . Context ()
108107
109108 conn , err := mysql .Connect (ctx , & vtParams )
110109 require .Nilf (t , err , "unable to connect mysql: %v" , err )
@@ -119,7 +118,7 @@ func TestTimeout(t *testing.T) {
119118
120119// TestInvalidField tries to fetch invalid column and verifies the error.
121120func TestInvalidField (t * testing.T ) {
122- ctx := context . Background ()
121+ ctx := t . Context ()
123122
124123 conn , err := mysql .Connect (ctx , & vtParams )
125124 require .Nilf (t , err , "unable to connect mysql: %v" , err )
@@ -134,7 +133,7 @@ func TestInvalidField(t *testing.T) {
134133
135134// TestWarnings validates the behaviour of SHOW WARNINGS.
136135func TestWarnings (t * testing.T ) {
137- ctx := context . Background ()
136+ ctx := t . Context ()
138137
139138 conn , err := mysql .Connect (ctx , & vtParams )
140139 require .NoError (t , err )
@@ -175,7 +174,7 @@ func TestWarnings(t *testing.T) {
175174// TestSelectWithUnauthorizedUser verifies that an unauthorized user
176175// is not able to read from the table.
177176func TestSelectWithUnauthorizedUser (t * testing.T ) {
178- ctx := context . Background ()
177+ ctx := t . Context ()
179178
180179 tmpVtParam := vtParams
181180 tmpVtParam .Uname = "testuser2"
0 commit comments