-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver_test.go
52 lines (48 loc) · 1.19 KB
/
driver_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
46
47
48
49
50
51
52
package polypheny
import (
testing "testing"
)
func TestParseDSN(t *testing.T) {
// wrong dsn format
dsn := "localhost:20590"
addr, user, password, err := parseDSN(dsn)
if err == nil {
t.Errorf("Expecting ClientError but got: %s %s %s", addr, user, password)
}
dsn = "localhost:20590,pa"
addr, user, password, err = parseDSN(dsn)
if err == nil {
t.Errorf("Expecting ClientError but got: %s %s %s", addr, user, password)
}
dsn = "localhost:20590,pa:"
addr, user, password, err = parseDSN(dsn)
if err != nil {
t.Errorf("Error. Got: %s %s %s %s", addr, user, password, err.Error())
}
if addr != "localhost:20590" || user != "pa" || password != "" {
t.Errorf("Error. Got: %s %s %s", addr, user, password)
}
}
func TestOpen(t *testing.T) {
d := PolyphenyDriver{}
conn, err := d.Open("localhost:20590,pa:")
if err != nil {
t.Error(err)
}
conn.Close()
_, err = d.Open("localhost:20590,pa")
if err == nil {
t.Error("Expecting error")
}
}
func TestOpenConnector(t *testing.T) {
d := PolyphenyDriver{}
_, err := d.OpenConnector("localhost:20590,pa:")
if err != nil {
t.Error(err)
}
_, err = d.OpenConnector("localhost:20590,pa")
if err == nil {
t.Error("Expecting error")
}
}