-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils_test.go
46 lines (41 loc) · 1.37 KB
/
utils_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
package simplehstore
import (
"testing"
)
func TestPostgresPrefix(t *testing.T) {
Verbose = true
a := "postgres://user:[email protected]:5432/postgres?sslmode=disable"
s, dbname := rebuildConnectionString(a, true)
if a != s {
t.Errorf("Error, the connection string could not be picked apart correctly: %s != %s", a, s)
}
if dbname != "postgres" {
t.Errorf("Error, the connection string could not be picked apart correctly. dbname != postgres, but: %s", dbname)
}
}
func TestArgs(t *testing.T) {
Verbose = true
a := "postgres://user:[email protected]:5432/postgres?user=myuser&password=mypass&sslmode=enable"
s, _ := rebuildConnectionString(a, true)
if a != s {
t.Errorf("Error, the connection string could not be picked apart correctly: %s != %s", a, s)
}
}
func TestCIDSN(t *testing.T) {
Verbose = true
a := "postgres:@127.0.0.1"
b := "postgres://[email protected]:5432/postgres?sslmode=disable"
s, _ := rebuildConnectionString(a, true)
if s != b {
t.Errorf("Error, the connection string could not be picked apart correctly:\n\t%s !=\n\t%s\ngiven %s", s, b, a)
}
}
func TestCIDSN2(t *testing.T) {
Verbose = true
a := "postgres:@127.0.0.1"
b := "postgres://[email protected]:5432/?sslmode=disable"
s, _ := rebuildConnectionString(a, false)
if s != b {
t.Errorf("Error, the connection string could not be picked apart correctly:\n\t%s !=\n\t%s\ngiven %s", s, b, a)
}
}