Skip to content

Fix integration tests related to index and constraint create/drop #886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 53 additions & 42 deletions packages/neo4j-driver/test/rx/summary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,11 @@ describe('#integration-rx summary', () => {
return
}

await verifyUpdates(runnable, 'CREATE INDEX on :Label(prop)', null, {
const query = isNewConstraintIndexSyntax(protocolVersion)
? 'CREATE INDEX FOR (l:Label) ON (l.prop)'
: 'CREATE INDEX ON :Label(prop)'

await verifyUpdates(runnable, query, null, {
nodesCreated: 0,
nodesDeleted: 0,
relationshipsCreated: 0,
Expand Down Expand Up @@ -467,12 +471,18 @@ describe('#integration-rx summary', () => {
// first create the to-be-dropped index
const session = driver.session()
try {
await session.run('CREATE INDEX on :Label(prop)')
const query = isNewConstraintIndexSyntax(protocolVersion)
? 'CREATE INDEX l_prop FOR (l:Label) ON (l.prop)'
: 'CREATE INDEX ON :Label(prop)'
await session.run(query)
} finally {
await session.close()
}

await verifyUpdates(runnable, 'DROP INDEX on :Label(prop)', null, {
const query = isNewConstraintIndexSyntax(protocolVersion)
? 'DROP INDEX l_prop'
: 'DROP INDEX ON :Label(prop)'
await verifyUpdates(runnable, query, null, {
nodesCreated: 0,
nodesDeleted: 0,
relationshipsCreated: 0,
Expand All @@ -499,24 +509,22 @@ describe('#integration-rx summary', () => {
return
}

await verifyUpdates(
runnable,
'CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE',
null,
{
nodesCreated: 0,
nodesDeleted: 0,
relationshipsCreated: 0,
relationshipsDeleted: 0,
propertiesSet: 0,
labelsAdded: 0,
labelsRemoved: 0,
indexesAdded: 0,
indexesRemoved: 0,
constraintsAdded: 1,
constraintsRemoved: 0
}
)
const query = isNewConstraintIndexSyntax(protocolVersion)
? 'CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS UNIQUE'
: 'CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE'
await verifyUpdates(runnable, query, null, {
nodesCreated: 0,
nodesDeleted: 0,
relationshipsCreated: 0,
relationshipsDeleted: 0,
propertiesSet: 0,
labelsAdded: 0,
labelsRemoved: 0,
indexesAdded: 0,
indexesRemoved: 0,
constraintsAdded: 1,
constraintsRemoved: 0
})
}

/**
Expand All @@ -535,31 +543,30 @@ describe('#integration-rx summary', () => {
// first create the to-be-dropped index
const session = driver.session()
try {
await session.run(
'CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE'
)
const query = isNewConstraintIndexSyntax(protocolVersion)
? 'CREATE CONSTRAINT book_isbn FOR (book:Book) REQUIRE book.isbn IS UNIQUE'
: 'CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE'
await session.run(query)
} finally {
await session.close()
}

await verifyUpdates(
runnable,
'DROP CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE',
null,
{
nodesCreated: 0,
nodesDeleted: 0,
relationshipsCreated: 0,
relationshipsDeleted: 0,
propertiesSet: 0,
labelsAdded: 0,
labelsRemoved: 0,
indexesAdded: 0,
indexesRemoved: 0,
constraintsAdded: 0,
constraintsRemoved: 1
}
)
const query = isNewConstraintIndexSyntax(protocolVersion)
? 'DROP CONSTRAINT book_isbn'
: 'DROP CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE'
await verifyUpdates(runnable, query, null, {
nodesCreated: 0,
nodesDeleted: 0,
relationshipsCreated: 0,
relationshipsDeleted: 0,
propertiesSet: 0,
labelsAdded: 0,
labelsRemoved: 0,
indexesAdded: 0,
indexesRemoved: 0,
constraintsAdded: 0,
constraintsRemoved: 1
})
}

/**
Expand Down Expand Up @@ -764,4 +771,8 @@ describe('#integration-rx summary', () => {
await session.close()
}
}

function isNewConstraintIndexSyntax (protocolVersion) {
return protocolVersion > 4.3
}
})