Skip to content

Commit

Permalink
v2 / Tests: update Travis; fix for older Neo4j versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
aseemk committed Jan 30, 2015
1 parent 43e0e8b commit 7e9efbc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ jdk:

env:
# test across multiple versions of Neo4j:
- NEO4J_VERSION="2.1.5"
- NEO4J_VERSION="2.2.0-M03"
- NEO4J_VERSION="2.1.6"
- NEO4J_VERSION="2.0.4"
- NEO4J_VERSION="1.9.8"

matrix:
# but we may want to allow our tests to fail against future, unstable
# versions of Neo4j. E.g. 2.2 introduces auth, and sets it by default.
# TODO: remove this once we've added auth support and fixed it for 2.2.
allow_failures:
- env: NEO4J_VERSION="2.2.0-M03"

before_install:
# install Neo4j locally:
Expand Down
39 changes: 34 additions & 5 deletions test-new/http._coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ neo4j = require '../'

{DB, TEST_LABEL, TEST_REL_TYPE} = fixtures

[DB_VERSION_STR, DB_VERSION_NUM] = []

TEST_NODE_A = new neo4j.Node
# _id will get filled in once we persist
labels: [TEST_LABEL]
Expand Down Expand Up @@ -141,6 +143,25 @@ describe 'GraphDatabase::http', ->

## Object parsing:

it '(query Neo4j version)', (_) ->
info = DB.http
method: 'GET'
path: '/db/data/'
, _

DB_VERSION_STR = info.neo4j_version or '0'
DB_VERSION_NUM = parseFloat DB_VERSION_STR, 10

if DB_VERSION_NUM < 2
throw new Error '*** node-neo4j v2 supports Neo4j v2+ only.
These tests will fail! ***'

# Neo4j <2.1.5 didn't return label info, so returned nodes won't have
# the labels we expect. Account for that:
if DB_VERSION_STR < '2.1.5'
delete TEST_NODE_A.labels
delete TEST_NODE_B.labels

it '(create test objects)', (_) ->
# NOTE: Using the old Cypher endpoint for simplicity here.
# Nicer than using the raw REST API to create these test objects,
Expand Down Expand Up @@ -222,9 +243,13 @@ describe 'GraphDatabase::http', ->
, _

expect(body).to.not.be.an.instanceOf neo4j.Node
expect(body.metadata).to.be.an 'object'
expect(body.metadata.id).to.equal TEST_NODE_A._id
expect(body.metadata.labels).to.eql TEST_NODE_A.labels

# NOTE: Neo4j <2.1.5 didn't return `metadata`, so can't rely on it:
if DB_VERSION_STR >= '2.1.5'
expect(body.metadata).to.be.an 'object'
expect(body.metadata.id).to.equal TEST_NODE_A._id
expect(body.metadata.labels).to.eql TEST_NODE_A.labels

expect(body.data).to.eql TEST_NODE_A.properties

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

expect(body.metadata).to.be.an 'object'
expect(body.metadata.id).to.equal TEST_REL._id
expect(body).to.not.be.an.instanceOf neo4j.Relationship

# NOTE: Neo4j <2.1.5 didn't return `metadata`, so can't rely on it:
if DB_VERSION_STR >= '2.1.5'
expect(body.metadata).to.be.an 'object'
expect(body.metadata.id).to.equal TEST_REL._id

expect(body.type).to.equal TEST_REL.type
expect(body.data).to.eql TEST_REL.properties

Expand Down

0 comments on commit 7e9efbc

Please sign in to comment.