Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable neo4j scheme #58

Merged
merged 1 commit into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions neo4j/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ type Driver interface {
// In order to connect to a single instance database, you need to pass a URI with scheme 'bolt'
// driver, err = NewDriver("bolt://db.server:7687", BasicAuth(username, password))
//
// In order to connect to a causal cluster database, you need to pass a URI with scheme 'bolt+routing' and its host
// part set to be one of the core cluster members.
// In order to connect to a causal cluster database, you need to pass a URI with scheme 'bolt+routing' or 'neo4j'
// and its host part set to be one of the core cluster members. Please note that 'bolt+routing' scheme will be
// removed with 2.0 series of drivers.
// driver, err = NewDriver("bolt+routing://core.db.server:7687", BasicAuth(username, password))
//
// You can override default configuration options by providing a configuration function(s)
Expand All @@ -66,7 +67,7 @@ func NewDriver(target string, auth AuthToken, configurers ...func(*Config)) (Dri
return nil, err
}

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

Expand Down
34 changes: 34 additions & 0 deletions neo4j/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,47 @@
package neo4j

import (
. "github.com/neo4j/neo4j-go-driver/neo4j/utils/test"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)

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

Context("URI", func() {
It("should support bolt:// scheme", func() {
driver, err := NewDriver("bolt://localhost:7687", NoAuth())

Expect(err).To(BeNil())
Expect(driver).NotTo(BeNil())
Expect(driver.Target().Scheme).To(BeIdenticalTo("bolt"))
})

It("should support bolt+routing:// scheme", func() {
driver, err := NewDriver("bolt+routing://localhost:7687", NoAuth())

Expect(err).To(BeNil())
Expect(driver).NotTo(BeNil())
Expect(driver.Target().Scheme).To(BeIdenticalTo("bolt+routing"))
})

It("should support neo4j:// scheme", func() {
driver, err := NewDriver("neo4j://localhost:7687", NoAuth())

Expect(err).To(BeNil())
Expect(driver).NotTo(BeNil())
Expect(driver.Target().Scheme).To(BeIdenticalTo("neo4j"))
})

It("should error anotherscheme:// scheme", func() {
driver, err := NewDriver("anotherscheme://localhost:7687", NoAuth())

Expect(driver).To(BeNil())
Expect(err).To(BeGenericError(ContainSubstring("url scheme anotherscheme is not supported")))
})
})

When("constructed with bolt://localhost:7687", func() {
driver, err := NewDriver("bolt://localhost:7687", NoAuth())

Expand Down