forked from mattn/go-oci8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oci8_test.go
46 lines (39 loc) · 1.47 KB
/
oci8_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 oci8
import (
"reflect"
"testing"
"time"
)
func TestParseDSN(t *testing.T) {
var (
pacific *time.Location
err error
)
if pacific, err = time.LoadLocation("America/Los_Angeles"); err != nil {
panic(err)
}
var dsnTests = []struct {
dsnString string
expectedDSN *DSN
}{
{"oracle://xxmc:xxmc@107.20.30.169:1521/ORCL?loc=America%2FLos_Angeles", &DSN{Username: "xxmc", Password: "xxmc", Connect: "107.20.30.169:1521/ORCL", prefetch_rows: 10, Location: pacific}},
{"xxmc/xxmc@107.20.30.169:1521/ORCL?loc=America%2FLos_Angeles", &DSN{Username: "xxmc", Password: "xxmc", Connect: "107.20.30.169:1521/ORCL", prefetch_rows: 10, Location: pacific}},
{"xxmc/xxmc@107.20.30.169:1521/ORCL", &DSN{Username: "xxmc", Password: "xxmc", Connect: "107.20.30.169:1521/ORCL", prefetch_rows: 10, Location: time.Local}},
{"xxmc/xxmc@107.20.30.169/ORCL", &DSN{Username: "xxmc", Password: "xxmc", Connect: "107.20.30.169/ORCL", prefetch_rows: 10, Location: time.Local}},
}
for _, tt := range dsnTests {
actualDSN, err := ParseDSN(tt.dsnString)
if err != nil {
t.Errorf("ParseDSN(%s) got error: %+v", tt.dsnString, err)
}
if !reflect.DeepEqual(actualDSN, tt.expectedDSN) {
t.Errorf("ParseDSN(%s): expected %+v, actual %+v", tt.dsnString, tt.expectedDSN, actualDSN)
}
}
}
func TestIsBadConn(t *testing.T) {
var errorCode = "ORA-03114"
if !isBadConnection(errorCode) {
t.Errorf("TestIsBadConn: expected %+v, actual %+v", true, isBadConnection(errorCode))
}
}