Skip to content

Commit 9f4fe8a

Browse files
committed
Fix integration tests related to index and constraint create/drop
The syntax for creating and dropping constraint in Neo4j 5.0 changed. `ON` keyword was replaced by `FOR` and `ASSERT` replaced by `REQUIRED`.
1 parent e38d125 commit 9f4fe8a

File tree

1 file changed

+55
-42
lines changed

1 file changed

+55
-42
lines changed

packages/neo4j-driver/test/rx/summary.test.js

+55-42
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,12 @@ describe('#integration-rx summary', () => {
436436
return
437437
}
438438

439-
await verifyUpdates(runnable, 'CREATE INDEX on :Label(prop)', null, {
439+
const query =
440+
protocolVersion > 4.2
441+
? 'CREATE INDEX FOR :Label(prop)'
442+
: 'CREATE INDEX ON :Label(prop)'
443+
444+
await verifyUpdates(runnable, query, null, {
440445
nodesCreated: 0,
441446
nodesDeleted: 0,
442447
relationshipsCreated: 0,
@@ -467,12 +472,20 @@ describe('#integration-rx summary', () => {
467472
// first create the to-be-dropped index
468473
const session = driver.session()
469474
try {
470-
await session.run('CREATE INDEX on :Label(prop)')
475+
const query =
476+
protocolVersion > 4.2
477+
? 'CREATE INDEX FOR :Label(prop)'
478+
: 'CREATE INDEX ON :Label(prop)'
479+
await session.run(query)
471480
} finally {
472481
await session.close()
473482
}
474483

475-
await verifyUpdates(runnable, 'DROP INDEX on :Label(prop)', null, {
484+
const query =
485+
protocolVersion > 4.2
486+
? 'DROP INDEX FOR :Label(prop)'
487+
: 'DROP INDEX ON :Label(prop)'
488+
await verifyUpdates(runnable, query, null, {
476489
nodesCreated: 0,
477490
nodesDeleted: 0,
478491
relationshipsCreated: 0,
@@ -499,24 +512,23 @@ describe('#integration-rx summary', () => {
499512
return
500513
}
501514

502-
await verifyUpdates(
503-
runnable,
504-
'CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE',
505-
null,
506-
{
507-
nodesCreated: 0,
508-
nodesDeleted: 0,
509-
relationshipsCreated: 0,
510-
relationshipsDeleted: 0,
511-
propertiesSet: 0,
512-
labelsAdded: 0,
513-
labelsRemoved: 0,
514-
indexesAdded: 0,
515-
indexesRemoved: 0,
516-
constraintsAdded: 1,
517-
constraintsRemoved: 0
518-
}
519-
)
515+
const query =
516+
protocolVersion > 4.2
517+
? 'CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS UNIQUE'
518+
: 'CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE'
519+
await verifyUpdates(runnable, query, null, {
520+
nodesCreated: 0,
521+
nodesDeleted: 0,
522+
relationshipsCreated: 0,
523+
relationshipsDeleted: 0,
524+
propertiesSet: 0,
525+
labelsAdded: 0,
526+
labelsRemoved: 0,
527+
indexesAdded: 0,
528+
indexesRemoved: 0,
529+
constraintsAdded: 1,
530+
constraintsRemoved: 0
531+
})
520532
}
521533

522534
/**
@@ -535,31 +547,32 @@ describe('#integration-rx summary', () => {
535547
// first create the to-be-dropped index
536548
const session = driver.session()
537549
try {
538-
await session.run(
539-
'CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE'
540-
)
550+
const query =
551+
protocolVersion > 4.2
552+
? 'CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS UNIQUE'
553+
: 'CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE'
554+
await session.run(query)
541555
} finally {
542556
await session.close()
543557
}
544558

545-
await verifyUpdates(
546-
runnable,
547-
'DROP CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE',
548-
null,
549-
{
550-
nodesCreated: 0,
551-
nodesDeleted: 0,
552-
relationshipsCreated: 0,
553-
relationshipsDeleted: 0,
554-
propertiesSet: 0,
555-
labelsAdded: 0,
556-
labelsRemoved: 0,
557-
indexesAdded: 0,
558-
indexesRemoved: 0,
559-
constraintsAdded: 0,
560-
constraintsRemoved: 1
561-
}
562-
)
559+
const query =
560+
protocolVersion > 4.2
561+
? 'DROP CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS UNIQUE'
562+
: 'DROP CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE'
563+
await verifyUpdates(runnable, query, null, {
564+
nodesCreated: 0,
565+
nodesDeleted: 0,
566+
relationshipsCreated: 0,
567+
relationshipsDeleted: 0,
568+
propertiesSet: 0,
569+
labelsAdded: 0,
570+
labelsRemoved: 0,
571+
indexesAdded: 0,
572+
indexesRemoved: 0,
573+
constraintsAdded: 0,
574+
constraintsRemoved: 1
575+
})
563576
}
564577

565578
/**

0 commit comments

Comments
 (0)