Skip to content

Commit 9347396

Browse files
authored
Merge pull request neo4j#58 from ali-ince/1.7-enable-neo4j
Enable neo4j scheme
2 parents e3abb83 + 05b400d commit 9347396

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

neo4j/driver.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ type Driver interface {
5252
// In order to connect to a single instance database, you need to pass a URI with scheme 'bolt'
5353
// driver, err = NewDriver("bolt://db.server:7687", BasicAuth(username, password))
5454
//
55-
// In order to connect to a causal cluster database, you need to pass a URI with scheme 'bolt+routing' and its host
56-
// part set to be one of the core cluster members.
55+
// In order to connect to a causal cluster database, you need to pass a URI with scheme 'bolt+routing' or 'neo4j'
56+
// and its host part set to be one of the core cluster members. Please note that 'bolt+routing' scheme will be
57+
// removed with 2.0 series of drivers.
5758
// driver, err = NewDriver("bolt+routing://core.db.server:7687", BasicAuth(username, password))
5859
//
5960
// You can override default configuration options by providing a configuration function(s)
@@ -66,7 +67,7 @@ func NewDriver(target string, auth AuthToken, configurers ...func(*Config)) (Dri
6667
return nil, err
6768
}
6869

69-
if parsed.Scheme != "bolt" && parsed.Scheme != "bolt+routing" {
70+
if parsed.Scheme != "bolt" && parsed.Scheme != "bolt+routing" && parsed.Scheme != "neo4j" {
7071
return nil, newDriverError("url scheme %s is not supported", parsed.Scheme)
7172
}
7273

neo4j/driver_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,47 @@
2020
package neo4j
2121

2222
import (
23+
. "github.com/neo4j/neo4j-go-driver/neo4j/utils/test"
2324
. "github.com/onsi/ginkgo"
2425
. "github.com/onsi/ginkgo/extensions/table"
2526
. "github.com/onsi/gomega"
2627
)
2728

2829
var _ = Describe("Driver", func() {
2930

31+
Context("URI", func() {
32+
It("should support bolt:// scheme", func() {
33+
driver, err := NewDriver("bolt://localhost:7687", NoAuth())
34+
35+
Expect(err).To(BeNil())
36+
Expect(driver).NotTo(BeNil())
37+
Expect(driver.Target().Scheme).To(BeIdenticalTo("bolt"))
38+
})
39+
40+
It("should support bolt+routing:// scheme", func() {
41+
driver, err := NewDriver("bolt+routing://localhost:7687", NoAuth())
42+
43+
Expect(err).To(BeNil())
44+
Expect(driver).NotTo(BeNil())
45+
Expect(driver.Target().Scheme).To(BeIdenticalTo("bolt+routing"))
46+
})
47+
48+
It("should support neo4j:// scheme", func() {
49+
driver, err := NewDriver("neo4j://localhost:7687", NoAuth())
50+
51+
Expect(err).To(BeNil())
52+
Expect(driver).NotTo(BeNil())
53+
Expect(driver.Target().Scheme).To(BeIdenticalTo("neo4j"))
54+
})
55+
56+
It("should error anotherscheme:// scheme", func() {
57+
driver, err := NewDriver("anotherscheme://localhost:7687", NoAuth())
58+
59+
Expect(driver).To(BeNil())
60+
Expect(err).To(BeGenericError(ContainSubstring("url scheme anotherscheme is not supported")))
61+
})
62+
})
63+
3064
When("constructed with bolt://localhost:7687", func() {
3165
driver, err := NewDriver("bolt://localhost:7687", NoAuth())
3266

0 commit comments

Comments
 (0)