@@ -38,20 +38,22 @@ func connect() factory.Factory {
38
38
Host : "localhost" ,
39
39
Port : 3306 ,
40
40
DBName : "test" ,
41
- Username : "root " ,
42
- Password : "123 " ,
41
+ Username : "test " ,
42
+ Password : "test " ,
43
43
Charset : "utf8" ,
44
44
}))
45
45
}
46
46
47
47
func initTest (t * testing.T ) (err error ) {
48
48
sql_table := "CREATE TABLE IF NOT EXISTS `test_table` (" +
49
- "`id` INTEGER PRIMARY KEY AUTOINCREMENT," +
50
- "`username` VARCHAR(64) NULL," +
51
- "`password` VARCHAR(64) NULL," +
52
- "`createTime` TIMESTAMP default (datetime('now', 'localtime')));"
49
+ "`id` int(11) NOT NULL AUTO_INCREMENT," +
50
+ "`username` varchar(255) DEFAULT NULL," +
51
+ "`password` varchar(255) DEFAULT NULL," +
52
+ "`createTime` datetime DEFAULT NULL," +
53
+ "PRIMARY KEY (`id`)" +
54
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
53
55
54
- db , err := sql .Open ("mysql" , "root:123 @tcp(localhost :3306)/test?charset=utf8" )
56
+ db , err := sql .Open ("mysql" , "test:test @tcp(localhost8 :3306)/test?charset=utf8" )
55
57
if err != nil {
56
58
t .Fatal (err )
57
59
}
@@ -69,7 +71,7 @@ func initTest(t *testing.T) (err error) {
69
71
return nil
70
72
}
71
73
72
- func TestSqlite3 (t * testing.T ) {
74
+ func TestMysql (t * testing.T ) {
73
75
initTest (t )
74
76
var testV TestTable
75
77
@@ -112,7 +114,7 @@ func TestSqlite3(t *testing.T) {
112
114
t .Logf ("%v %v" , testV .Username , testV .Password )
113
115
}
114
116
115
- func TestSqliteTx (t * testing.T ) {
117
+ func TestMysqlTx (t * testing.T ) {
116
118
initTest (t )
117
119
var testV TestTable
118
120
0 commit comments