Skip to content

Commit 39f87de

Browse files
committed
v2 / Tests: update Travis; fix for older Neo4j versions.
1 parent 3b250da commit 39f87de

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

.travis.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ jdk:
99

1010
env:
1111
# test across multiple versions of Neo4j:
12-
- NEO4J_VERSION="2.1.5"
12+
- NEO4J_VERSION="2.2.0-M03"
13+
- NEO4J_VERSION="2.1.6"
1314
- NEO4J_VERSION="2.0.4"
14-
- NEO4J_VERSION="1.9.8"
15+
16+
matrix:
17+
# but we may want to allow our tests to fail against future, unstable
18+
# versions of Neo4j. E.g. 2.2 introduces auth, and sets it by default.
19+
# TODO: remove this once we've added auth support and fixed it for 2.2.
20+
allow_failures:
21+
- env: NEO4J_VERSION="2.2.0-M03"
1522

1623
before_install:
1724
# install Neo4j locally:

test-new/http._coffee

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ neo4j = require '../'
88

99
{DB, TEST_LABEL, TEST_REL_TYPE} = fixtures
1010

11+
[DB_VERSION_STR, DB_VERSION_NUM] = []
12+
1113
TEST_NODE_A = new neo4j.Node
1214
# _id will get filled in once we persist
1315
labels: [TEST_LABEL]
@@ -141,6 +143,25 @@ describe 'GraphDatabase::http', ->
141143

142144
## Object parsing:
143145

146+
it '(query Neo4j version)', (_) ->
147+
info = DB.http
148+
method: 'GET'
149+
path: '/db/data/'
150+
, _
151+
152+
DB_VERSION_STR = info.neo4j_version or '0'
153+
DB_VERSION_NUM = parseFloat DB_VERSION_STR, 10
154+
155+
if DB_VERSION_NUM < 2
156+
throw new Error '*** node-neo4j v2 supports Neo4j v2+ only.
157+
These tests will fail! ***'
158+
159+
# Neo4j <2.1.5 didn't return label info, so returned nodes won't have
160+
# the labels we expect. Account for that:
161+
if DB_VERSION_STR < '2.1.5'
162+
TEST_NODE_A.labels = null
163+
TEST_NODE_B.labels = null
164+
144165
it '(create test objects)', (_) ->
145166
# NOTE: Using the old Cypher endpoint for simplicity here.
146167
# Nicer than using the raw REST API to create these test objects,
@@ -222,9 +243,13 @@ describe 'GraphDatabase::http', ->
222243
, _
223244

224245
expect(body).to.not.be.an.instanceOf neo4j.Node
225-
expect(body.metadata).to.be.an 'object'
226-
expect(body.metadata.id).to.equal TEST_NODE_A._id
227-
expect(body.metadata.labels).to.eql TEST_NODE_A.labels
246+
247+
# NOTE: Neo4j <2.1.5 didn't return `metadata`, so can't rely on it:
248+
if DB_VERSION_STR >= '2.1.5'
249+
expect(body.metadata).to.be.an 'object'
250+
expect(body.metadata.id).to.equal TEST_NODE_A._id
251+
expect(body.metadata.labels).to.eql TEST_NODE_A.labels
252+
228253
expect(body.data).to.eql TEST_NODE_A.properties
229254

230255
it 'should not parse relationships for raw responses', (_) ->
@@ -234,9 +259,13 @@ describe 'GraphDatabase::http', ->
234259
raw: true
235260
, _
236261

237-
expect(body.metadata).to.be.an 'object'
238-
expect(body.metadata.id).to.equal TEST_REL._id
239262
expect(body).to.not.be.an.instanceOf neo4j.Relationship
263+
264+
# NOTE: Neo4j <2.1.5 didn't return `metadata`, so can't rely on it:
265+
if DB_VERSION_STR >= '2.1.5'
266+
expect(body.metadata).to.be.an 'object'
267+
expect(body.metadata.id).to.equal TEST_REL._id
268+
240269
expect(body.type).to.equal TEST_REL.type
241270
expect(body.data).to.eql TEST_REL.properties
242271

0 commit comments

Comments
 (0)