-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql_test.go
45 lines (40 loc) · 874 Bytes
/
mysql_test.go
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
41
42
43
44
45
package sqldb
import "testing"
func TestNewMySQL(t *testing.T) {
host := "10.0.0.1"
dbName := "db_name"
user := "user"
password := "password"
c := NewMySQL(host, dbName, user, password)
if c.Type != DBTypeMySQL {
t.Fatal("wrong db type", c.Type)
return
}
if c.Host != host {
t.Fatal("host does not match", c.Host, host)
return
}
if c.Port != defaultMySQLPort {
t.Fatal("default port not set")
return
}
if c.Name != dbName {
t.Fatal("db name does not match", c.Name, dbName)
return
}
if c.User != user {
t.Fatal("user does not match", c.User, user)
return
}
if c.Password != password {
t.Fatal("host does not match", c.Password, password)
return
}
}
func TestIsMySQL(t *testing.T) {
c := NewMySQL("10.0.0.1", "db_name", "user1", "password!")
if !c.IsMySQL() {
t.Fatal("DB type isn't detected as MySQL", c.Type)
return
}
}