-
Notifications
You must be signed in to change notification settings - Fork 37
/
dburl_test.go
31 lines (26 loc) · 935 Bytes
/
dburl_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
package dburl
import "testing"
func TestParse(t *testing.T) {
tests := []struct {
s string
d string
exp string
}{
{`pg:booktest:booktest@localhost/booktest`, `postgres`, `postgres://booktest:booktest@localhost/booktest`},
{`mssql://user:!234%23$@localhost:1580/dbname`, `mssql`, `server=localhost;port=1580;database=dbname;user id=user;password=!234#$`},
{`adodb://Microsoft.ACE.OLEDB.12.0?Extended+Properties="Text;HDR=NO;FMT=Delimited"`, `adodb`, `Provider=Microsoft.ACE.OLEDB.12.0;Data Source=.;Extended Properties="Text;HDR=NO;FMT=Delimited"`},
}
for i, test := range tests {
u, err := Parse(test.s)
if err != nil {
t.Errorf("test %d expected no error, got: %v", i, err)
continue
}
if u.Driver != test.d {
t.Errorf("test %d expected driver `%s`, got: `%s`", i, test.d, u.Driver)
}
if u.DSN != test.exp {
t.Errorf("test %d expected DSN `%s`, got: `%s`", i, test.exp, u.DSN)
}
}
}