MCPcopy
hub / github.com/go-sql-driver/mysql / runTests

Function runTests

driver_test.go:144–203  ·  view source on GitHub ↗
(t *testing.T, dsn string, tests ...func(dbt *DBTest))

Source from the content-addressed store, hash-verified

142}
143
144func runTests(t *testing.T, dsn string, tests ...func(dbt *DBTest)) {
145 if !available {
146 t.Skipf("MySQL server not running on %s", netAddr)
147 }
148
149 db, err := sql.Open(driverNameTest, dsn)
150 if err != nil {
151 t.Fatalf("connecting %q: %s", dsn, err)
152 }
153 defer db.Close()
154 if err = db.Ping(); err != nil {
155 t.Fatalf("connecting %q: %s", dsn, err)
156 }
157
158 dsn2 := dsn + "&interpolateParams=true"
159 var db2 *sql.DB
160 if _, err := ParseDSN(dsn2); err != errInvalidDSNUnsafeCollation {
161 db2, err = sql.Open(driverNameTest, dsn2)
162 if err != nil {
163 t.Fatalf("connecting %q: %s", dsn2, err)
164 }
165 defer db2.Close()
166 }
167
168 dsn3 := dsn + "&compress=true"
169 var db3 *sql.DB
170 db3, err = sql.Open(driverNameTest, dsn3)
171 if err != nil {
172 t.Fatalf("connecting %q: %s", dsn3, err)
173 }
174 defer db3.Close()
175
176 cleanupSql := "DROP TABLE IF EXISTS test"
177
178 for _, test := range tests {
179 t.Run("default", func(t *testing.T) {
180 dbt := &DBTest{t, db}
181 t.Cleanup(func() {
182 db.Exec(cleanupSql)
183 })
184 test(dbt)
185 })
186 if db2 != nil {
187 t.Run("interpolateParams", func(t *testing.T) {
188 dbt2 := &DBTest{t, db2}
189 t.Cleanup(func() {
190 db2.Exec(cleanupSql)
191 })
192 test(dbt2)
193 })
194 }
195 t.Run("compress", func(t *testing.T) {
196 dbt3 := &DBTest{t, db3}
197 t.Cleanup(func() {
198 db3.Exec(cleanupSql)
199 })
200 test(dbt3)
201 })

Callers 15

TestDateTimeFunction · 0.85
TestLongDataFunction · 0.85
TestLoadDataFunction · 0.85
TestTLSFunction · 0.85
TestCharsetFunction · 0.85
TestCollationFunction · 0.85
TestTimezoneConversionFunction · 0.85
TestPreparedManyColsFunction · 0.85
TestConcurrentFunction · 0.85
TestSQLInjectionFunction · 0.85

Calls 5

ParseDSNFunction · 0.85
OpenMethod · 0.80
PingMethod · 0.80
CloseMethod · 0.45
ExecMethod · 0.45

Tested by

no test coverage detected