@@ -25,37 +25,33 @@ func Test_MysqlBackend(t *testing.T) {
25
25
26
26
dbName := "test_" + strings .Replace (uuid .NewString (), "-" , "" , - 1 )
27
27
28
- test .TestBackend (t , test.Tester {
29
- New : func () backend.Backend {
30
- db , err := sql .Open ("mysql" , fmt .Sprintf ("%s:%s@/?parseTime=true&interpolateParams=true" , testUser , testPassword ))
31
- if err != nil {
32
- panic (err )
33
- }
34
-
35
- if _ , err := db .Exec ("CREATE DATABASE " + dbName ); err != nil {
36
- panic (errors .Wrap (err , "could not create database" ))
37
- }
38
-
39
- if err := db .Close (); err != nil {
40
- panic (err )
41
- }
42
-
43
- return NewMysqlBackend ("localhost" , 3306 , testUser , testPassword , dbName , backend .WithStickyTimeout (0 ))
44
- },
45
-
46
- Teardown : func () {
47
- db , err := sql .Open ("mysql" , fmt .Sprintf ("%s:%s@/?parseTime=true&interpolateParams=true" , testUser , testPassword ))
48
- if err != nil {
49
- panic (err )
50
- }
51
-
52
- if _ , err := db .Exec ("DROP DATABASE IF EXISTS " + dbName ); err != nil {
53
- panic (errors .Wrap (err , "could not drop database" ))
54
- }
55
-
56
- if err := db .Close (); err != nil {
57
- panic (err )
58
- }
59
- },
28
+ test .BackendTest (t , func () backend.Backend {
29
+ db , err := sql .Open ("mysql" , fmt .Sprintf ("%s:%s@/?parseTime=true&interpolateParams=true" , testUser , testPassword ))
30
+ if err != nil {
31
+ panic (err )
32
+ }
33
+
34
+ if _ , err := db .Exec ("CREATE DATABASE " + dbName ); err != nil {
35
+ panic (errors .Wrap (err , "could not create database" ))
36
+ }
37
+
38
+ if err := db .Close (); err != nil {
39
+ panic (err )
40
+ }
41
+
42
+ return NewMysqlBackend ("localhost" , 3306 , testUser , testPassword , dbName , backend .WithStickyTimeout (0 ))
43
+ }, func (b backend.Backend ) {
44
+ db , err := sql .Open ("mysql" , fmt .Sprintf ("%s:%s@/?parseTime=true&interpolateParams=true" , testUser , testPassword ))
45
+ if err != nil {
46
+ panic (err )
47
+ }
48
+
49
+ if _ , err := db .Exec ("DROP DATABASE IF EXISTS " + dbName ); err != nil {
50
+ panic (errors .Wrap (err , "could not drop database" ))
51
+ }
52
+
53
+ if err := db .Close (); err != nil {
54
+ panic (err )
55
+ }
60
56
})
61
57
}
0 commit comments