75
76
// NewMySQLConfig returns a new MySQL config for test
78
>
return &config.SQL{
79
>
User: testMySQLUser,
80
>
Password: testMySQLPassword,
81
>
ConnectAddr: net.JoinHostPort(
82
>
environment.GetMySQLAddress(),
83
>
strconv.Itoa(environment.GetMySQLPort()),
84
>
),
85
>
ConnectProtocol: testMySQLConnectionProtocol,
86
>
PluginName: mysql.PluginName,
87
>
DatabaseName: testMySQLDatabaseNamePrefix + shuffle.String(testMySQLDatabaseNameSuffix),
88
>
}
89
>
}
90
92
>
adminCfg := *cfg
93
>
// NOTE need to connect with empty name to create new database
94
>
adminCfg.DatabaseName = ""
95
>
96
>
db, err := sql.NewSQLAdminDB(sqlplugin.DbKindUnknown, &adminCfg, resolver.NewNoopResolver(), log.NewTestLogger(), metrics.NoopMetricsHandler)
97
>
if err != nil {
98
t.Fatalf("unable to create MySQL admin DB: %v", err)
99
}
101
103
>
if err != nil {
104
t.Fatalf("unable to create MySQL database: %v", err)
105
}
106
}
107
109
>
db, err := sql.NewSQLAdminDB(sqlplugin.DbKindUnknown, cfg, resolver.NewNoopResolver(), log.NewTestLogger(), metrics.NoopMetricsHandler)
110
>
if err != nil {
111
t.Fatalf("unable to create MySQL admin DB: %v", err)
112
}
114
116
>
if err != nil {
117
t.Fatal(err)
118
}
119
121
>
if err != nil {
122
t.Fatal(err)
123
}
124
126
>
if err = db.Exec(stmt); err != nil {
127
t.Fatal(err)
128
}
129
}
130
132
>
if err != nil {
133
t.Fatal(err)
134
}
135
137
>
if err != nil {
138
t.Fatal(err)
139
}
140
142
>
if err = db.Exec(stmt); err != nil {
143
t.Fatal(err)
144
}