Skip to content

Commit a37c02d

Browse files
author
c9845
committed
Fix func for handling default mariadb config not setting db name properly. Still have to fix MySQL and MS SQL.
1 parent 6177808 commit a37c02d

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

mariadb.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ func NewMariaDB(host, dbName, user, password string) *Config {
1010
c.Type = DBTypeMariaDB
1111
c.Host = host
1212
c.Port = defaultMariaDBPort
13+
c.Name = dbName
1314
c.User = user
1415
c.Password = password
1516

mariadb_test.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,37 @@ package sqldb
33
import "testing"
44

55
func TestNewMariaDB(t *testing.T) {
6-
c := NewMariaDB("10.0.0.1", "db_name", "user1", "password1")
6+
host := "10.0.0.1"
7+
dbName := "db_name"
8+
user := "user"
9+
password := "password"
10+
11+
c := NewMariaDB(host, dbName, user, password)
712
if c.Type != DBTypeMariaDB {
813
t.FailNow()
914
return
1015
}
16+
17+
if c.Host != host {
18+
t.Fatal("host does not match", c.Host, host)
19+
return
20+
}
21+
if c.Port != defaultMariaDBPort {
22+
t.Fatal("default port not set")
23+
return
24+
}
25+
if c.Name != dbName {
26+
t.Fatal("db name does not match", c.Name, dbName)
27+
return
28+
}
29+
if c.User != user {
30+
t.Fatal("user does not match", c.User, user)
31+
return
32+
}
33+
if c.Password != password {
34+
t.Fatal("host does not match", c.Password, password)
35+
return
36+
}
1137
}
1238

1339
func TestIsMariaDB(t *testing.T) {

0 commit comments

Comments
 (0)