-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysql_test.go
More file actions
40 lines (33 loc) · 805 Bytes
/
mysql_test.go
File metadata and controls
40 lines (33 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package testdock
import (
"database/sql"
"testing"
"time"
)
func Test_MySQLDB(t *testing.T) {
t.Parallel()
db, informer := GetMySQLConn(t,
DefaultMySQLDSN,
WithMigrations("migrations/pg/goose", GooseMigrateFactoryMySQL),
WithRetryTimeout(time.Second*5),
WithTotalRetryDuration(time.Second*60), //nolint:mnd // for Docker 30s not enough
)
checkInformer(t, DefaultMySQLDSN, informer)
testSQLHelper(t, db)
}
func testSQLHelper(t *testing.T, db *sql.DB) {
t.Helper()
rows, err := db.Query("SELECT name FROM test_table")
if err != nil {
t.Fatalf("error: %s", err)
}
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
t.Fatalf("error: %s", err)
}
if name != "test" { //nolint:goconst // ok
t.Fatalf("expected 'test', got '%s'", name)
}
}
}