-
Notifications
You must be signed in to change notification settings - Fork 13
/
conn_test.go
58 lines (50 loc) · 998 Bytes
/
conn_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
53
54
55
56
57
58
package cq
import (
"database/sql/driver"
"flag"
. "launchpad.net/gocheck"
"log"
//"testing"
)
type ConnSuite struct{}
var (
_ = Suite(&ConnSuite{})
testURL = flag.String("testdb", "http://localhost:7474/", "the base url for the test db")
)
//func Test(t *testing.T) {
// TestingT(t)
//}
func openTest() driver.Conn {
db, err := Open(*testURL)
if err != nil {
log.Println("can't connect to db.")
return nil
}
return db
}
func (s *ConnSuite) TestOpen(c *C) {
db := openTest()
if db == nil {
c.Fatal("can't connect to test db: ", *testURL)
}
}
func (s *ConnSuite) TestPrepareNoParams(c *C) {
db := openTest()
if db == nil {
c.Fatal("can't connect to test db: ", *testURL)
}
stmt, err := db.Prepare("match (n) return n limit 1")
c.Assert(err, IsNil)
if stmt == nil {
c.Fatal("stmt is nil")
}
}
func (s *ConnSuite) TestBadURL(c *C) {
db, err := Open("")
if err == nil {
c.Fatal("err was nil!")
}
if db != nil {
c.Fatal("db should be nil:", db)
}
}