Skip to content

Commit

Permalink
Fix test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-ince committed Oct 11, 2018
1 parent 9b2c6af commit ebf991b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions neo4j/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func newDriverError(format string, args ...interface{}) gobolt.GenericError {
return &driverError{message: fmt.Sprintf(format, args...)}
}

func newSessionExpiredError(format string, args ...interface{}) error {
return &sessionExpiredError{message: fmt.Sprintf(format, args...)}
}

func newDatabaseError(classification, code, message string) gobolt.DatabaseError {
return &databaseError{code: code, message: message, classification: classification}
}
Expand Down
8 changes: 6 additions & 2 deletions neo4j/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ func handleRecordsPhase(runner *statementRunner, activeResult *neoResult) error
}

func transformError(runner *statementRunner, err error) error {
if gobolt.IsWriteError(err) && runner.accessMode == AccessModeRead {
return &sessionExpiredError{"write queries cannot be performed in read access mode"}
if gobolt.IsWriteError(err) {
if runner.accessMode == AccessModeRead {
return newDriverError("write queries cannot be performed in read access mode")
}

return newSessionExpiredError("server at %s no longer accepts writes", runner.connection.RemoteAddress())
}

return err
Expand Down
2 changes: 1 addition & 1 deletion neo4j/test-integration/values_unsupported_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var _ = Describe("Unsupported Types [V1]", func() {
testSend := func(data interface{}) {
result, err = session.Run("WITH $x RETURN 1", map[string]interface{}{"x": data})
Expect(err).To(BeConnectorErrorWithCode(0x501))
Expect(err).To(BeConnectorErrorWithDescription("unable to generate RUN message"))
Expect(err).To(BeConnectorErrorWithDescription("unable to generate run message"))
}

Context("Send", func() {
Expand Down

0 comments on commit ebf991b

Please sign in to comment.