Skip to content

Commit cd7fd7a

Browse files
committed
Fix test failures after latest server changes
1 parent d8539d0 commit cd7fd7a

File tree

6 files changed

+38
-33
lines changed

6 files changed

+38
-33
lines changed

test/rx/summary.test.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ describe('#integration-rx summary', () => {
578578
'The provided label is not in the database.'
579579
)
580580
expect(summary.notifications[0].description).toBe(
581-
'One of the labels in your query is not available in the database, make sure you didn\'t misspell it or that the label is available when you run this statement in your application (the missing label name is: ThisLabelDoesNotExist)'
581+
"One of the labels in your query is not available in the database, make sure you didn't misspell it or that the label is available when you run this statement in your application (the missing label name is: ThisLabelDoesNotExist)"
582582
)
583583
expect(summary.notifications[0].severity).toBe('WARNING')
584584
}
@@ -652,20 +652,25 @@ describe('#integration-rx summary', () => {
652652
}
653653

654654
async function dropConstraintsAndIndices (driver) {
655+
function getName (record) {
656+
const obj = record.toObject()
657+
const name = obj.description || obj.name
658+
if (!name) {
659+
throw new Error('unable to identify name of the constraint/index')
660+
}
661+
return name
662+
}
663+
655664
const session = driver.session()
656665
try {
657-
const constraints = await session.run(
658-
"CALL db.constraints() yield description RETURN 'DROP ' + description"
659-
)
666+
const constraints = await session.run('CALL db.constraints()')
660667
for (let i = 0; i < constraints.records.length; i++) {
661-
await session.run(constraints.records[0].get(0))
668+
await session.run(`DROP ${getName(constraints.records[i])}`)
662669
}
663670

664-
const indices = await session.run(
665-
"CALL db.indexes() yield description RETURN 'DROP ' + description"
666-
)
671+
const indices = await session.run('CALL db.indexes()')
667672
for (let i = 0; i < indices.records.length; i++) {
668-
await session.run(indices.records[0].get(0))
673+
await session.run(`DROP ${getName(indices.records[i])}`)
669674
}
670675
} finally {
671676
await session.close()

test/session.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ describe('#integration session', () => {
171171
it('should accept a statement object ', done => {
172172
// Given
173173
const statement = {
174-
text: 'RETURN 1 = {param} AS a',
174+
text: 'RETURN 1 = $param AS a',
175175
parameters: { param: 1 }
176176
}
177177

@@ -215,7 +215,7 @@ describe('#integration session', () => {
215215

216216
it('should expose summarize method for basic metadata ', done => {
217217
// Given
218-
const statement = 'CREATE (n:Label {prop:{prop}}) RETURN n'
218+
const statement = 'CREATE (n:Label {prop: $prop}) RETURN n'
219219
const params = { prop: 'string' }
220220
// When & Then
221221
session.run(statement, params).then(result => {
@@ -269,7 +269,7 @@ describe('#integration session', () => {
269269

270270
it('should expose plan ', done => {
271271
// Given
272-
const statement = 'EXPLAIN CREATE (n:Label {prop:{prop}}) RETURN n'
272+
const statement = 'EXPLAIN CREATE (n:Label {prop: $prop}) RETURN n'
273273
const params = { prop: 'string' }
274274
// When & Then
275275
session.run(statement, params).then(result => {
@@ -286,7 +286,7 @@ describe('#integration session', () => {
286286

287287
it('should expose profile ', done => {
288288
// Given
289-
const statement = 'PROFILE MATCH (n:Label {prop:{prop}}) RETURN n'
289+
const statement = 'PROFILE MATCH (n:Label {prop: $prop}) RETURN n'
290290
const params = { prop: 'string' }
291291
// When & Then
292292
session.run(statement, params).then(result => {
@@ -403,7 +403,7 @@ describe('#integration session', () => {
403403
throw Error()
404404
}
405405

406-
const statement = 'RETURN {param}'
406+
const statement = 'RETURN $param'
407407
const params = { param: unpackable }
408408
// When & Then
409409
session.run(statement, params).catch(ignore => {
@@ -883,20 +883,20 @@ describe('#integration session', () => {
883883
it('should be able to do nested queries', done => {
884884
session
885885
.run(
886-
'CREATE (knight:Person:Knight {name: {name1}, castle: {castle}})' +
887-
'CREATE (king:Person {name: {name2}, title: {title}})',
886+
'CREATE (knight:Person:Knight {name: $name1, castle: $castle})' +
887+
'CREATE (king:Person {name: $name2, title: $title})',
888888
{ name1: 'Lancelot', castle: 'Camelot', name2: 'Arthur', title: 'King' }
889889
)
890890
.then(() => {
891891
session
892892
.run(
893-
'MATCH (knight:Person:Knight) WHERE knight.castle = {castle} RETURN id(knight) AS knight_id',
893+
'MATCH (knight:Person:Knight) WHERE knight.castle = $castle RETURN id(knight) AS knight_id',
894894
{ castle: 'Camelot' }
895895
)
896896
.subscribe({
897897
onNext: record => {
898898
session.run(
899-
'MATCH (knight) WHERE id(knight) = {id} MATCH (king:Person) WHERE king.name = {king} CREATE (knight)-[:DEFENDS]->(king)',
899+
'MATCH (knight) WHERE id(knight) = $id MATCH (king:Person) WHERE king.name = $king CREATE (knight)-[:DEFENDS]->(king)',
900900
{ id: record.get('knight_id'), king: 'Arthur' }
901901
)
902902
},

test/spatial-types.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('#integration spatial-types', () => {
110110
it('should receive 2D points with crs', done => {
111111
testReceivingOfPoints(
112112
done,
113-
`RETURN point({x: 2.3, y: 4.5, crs: 'WGS-84'})`,
113+
'RETURN point({x: 2.3, y: 4.5, crs: \'WGS-84\'})',
114114
point => {
115115
expect(isPoint(point)).toBeTruthy()
116116
expect(point.srid).toEqual(WGS_84_2D_CRS_CODE)
@@ -138,7 +138,7 @@ describe('#integration spatial-types', () => {
138138
it('should receive 3D points with crs', done => {
139139
testReceivingOfPoints(
140140
done,
141-
`RETURN point({x: 34.76, y: 11.9, z: -99.01, crs: 'WGS-84-3D'})`,
141+
'RETURN point({x: 34.76, y: 11.9, z: -99.01, crs: \'WGS-84-3D\'})',
142142
point => {
143143
expect(isPoint(point)).toBeTruthy()
144144
expect(point.srid).toEqual(WGS_84_3D_CRS_CODE)
@@ -166,10 +166,10 @@ describe('#integration spatial-types', () => {
166166
it('should send and receive array of 2D points', done => {
167167
const arrayOfPoints = [
168168
new Point(WGS_84_2D_CRS_CODE, 12.3, 11.2),
169-
new Point(WGS_84_2D_CRS_CODE, 2.45, 91.302),
170-
new Point(WGS_84_2D_CRS_CODE, 0.12, -99.9),
171-
new Point(WGS_84_2D_CRS_CODE, 93.75, 123.213),
172-
new Point(WGS_84_2D_CRS_CODE, 111.13, -90.1),
169+
new Point(WGS_84_2D_CRS_CODE, 2.45, 81.302),
170+
new Point(WGS_84_2D_CRS_CODE, 0.12, -89.9),
171+
new Point(WGS_84_2D_CRS_CODE, 93.75, 23.213),
172+
new Point(WGS_84_2D_CRS_CODE, 111.13, -70.1),
173173
new Point(WGS_84_2D_CRS_CODE, 43.99, -1)
174174
]
175175

test/stress.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('#integration stress tests', () => {
4040

4141
const READ_QUERY = 'MATCH (n) RETURN n LIMIT 1'
4242
const WRITE_QUERY =
43-
'CREATE (person:Person:Employee {name: {name}, salary: {salary}}) RETURN person'
43+
'CREATE (person:Person:Employee {name: $name, salary: $salary}) RETURN person'
4444

4545
const TEST_MODE = modeFromEnvOrDefault('STRESS_TEST_MODE')
4646
const DATABASE_URI = fromEnvOrDefault(
@@ -231,7 +231,7 @@ describe('#integration stress tests', () => {
231231
.run(query, params)
232232
.then(result => {
233233
context.queryCompleted(result, accessMode)
234-
context.log(commandId, `Query completed successfully`)
234+
context.log(commandId, 'Query completed successfully')
235235

236236
return session.close().then(() => {
237237
const possibleError = verifyQueryResult(result)
@@ -272,7 +272,7 @@ describe('#integration stress tests', () => {
272272
resultPromise
273273
.then(result => {
274274
context.queryCompleted(result, accessMode, session.lastBookmark())
275-
context.log(commandId, `Transaction function executed successfully`)
275+
context.log(commandId, 'Transaction function executed successfully')
276276

277277
return session.close().then(() => {
278278
const possibleError = verifyQueryResult(result)
@@ -322,7 +322,7 @@ describe('#integration stress tests', () => {
322322
})
323323
.then(() => {
324324
context.queryCompleted(result, accessMode, session.lastBookmark())
325-
context.log(commandId, `Transaction committed successfully`)
325+
context.log(commandId, 'Transaction committed successfully')
326326

327327
return session.close().then(() => {
328328
callback(commandError)
@@ -341,7 +341,7 @@ describe('#integration stress tests', () => {
341341

342342
function verifyQueryResult (result) {
343343
if (!result) {
344-
return new Error(`Received undefined result`)
344+
return new Error('Received undefined result')
345345
} else if (result.records.length === 0) {
346346
// it is ok to receive no nodes back for read queries at the beginning of the test
347347
return null

test/transaction.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('#integration transaction', () => {
9494
const tx = session.beginTransaction()
9595
tx.run("RETURN 'foo' AS res")
9696
.then(result => {
97-
tx.run('CREATE ({name: {param}})', {
97+
tx.run('CREATE ({name: $param})', {
9898
param: result.records[0].get('res')
9999
})
100100
.then(() => {

test/types.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('#integration path values', () => {
179179
})
180180

181181
describe('#integration byte arrays', () => {
182-
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL
182+
const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL
183183

184184
beforeAll(() => {
185185
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000
@@ -213,7 +213,7 @@ describe('#integration byte arrays', () => {
213213
const driver = neo4j.driver('bolt://localhost', sharedNeo4j.authToken)
214214
const session = driver.session()
215215
session
216-
.run('RETURN {array}', { array: randomByteArray(42) })
216+
.run('RETURN $array', { array: randomByteArray(42) })
217217
.catch(error => {
218218
expect(error.message).toEqual(
219219
'Byte arrays are not supported by the database this driver is connected to'
@@ -255,7 +255,7 @@ function runReturnQuery (driver, actual, expected) {
255255
const session = driver.session()
256256
return new Promise((resolve, reject) => {
257257
session
258-
.run('RETURN {val} as v', { val: actual })
258+
.run('RETURN $val as v', { val: actual })
259259
.then(result => {
260260
expect(result.records[0].get('v')).toEqual(expected || actual)
261261
})

0 commit comments

Comments
 (0)