Skip to content

Remove usage of drop procedures from IT Tests #975

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
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
26 changes: 20 additions & 6 deletions packages/neo4j-driver/test/rx/summary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('#integration-rx summary', () => {
session = driver.rxSession()

protocolVersion = await sharedNeo4j.cleanupAndGetProtocolVersion(driver)
await dropConstraintsAndIndices(driver)
await dropConstraintsAndIndices(driver, protocolVersion)
})

afterEach(async () => {
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('#integration-rx summary', () => {
await normalSession.close()
}

await dropConstraintsAndIndices(driver)
await dropConstraintsAndIndices(driver, protocolVersion)
})

afterEach(async () => {
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('#integration-rx summary', () => {
await normalSession.close()
}

await dropConstraintsAndIndices(driver)
await dropConstraintsAndIndices(driver, protocolVersion)
})

afterEach(async () => {
Expand Down Expand Up @@ -755,16 +755,22 @@ describe('#integration-rx summary', () => {
expect(summary.counters.containsUpdates()).toBeFalsy()
}

async function dropConstraintsAndIndices (driver) {
async function dropConstraintsAndIndices (driver, protocolVersion) {
const session = driver.session()
try {
const constraints = await session.run('CALL db.constraints()')
const showConstraints = shouldUseShowConstraints(protocolVersion)
? 'SHOW CONSTRAINTS'
: 'CALL db.constraints()'
const constraints = await session.run(showConstraints)
for (let i = 0; i < constraints.records.length; i++) {
const name = constraints.records[i].toObject().name
await session.run('DROP CONSTRAINT ' + name) // ${getName(constraints.records[i])}`)
}

const indices = await session.run('CALL db.indexes()')
const showIndexes = shouldUseShowIndexes(protocolVersion)
? 'SHOW INDEXES'
: 'CALL db.indexes()'
const indices = await session.run(showIndexes)
for (let i = 0; i < indices.records.length; i++) {
const name = indices.records[i].toObject().name
await session.run('DROP INDEX ' + name) // ${getName(constraints.records[i])}`)
Expand All @@ -777,4 +783,12 @@ describe('#integration-rx summary', () => {
function isNewConstraintIndexSyntax (protocolVersion) {
return protocolVersion > 4.3
}

function shouldUseShowConstraints (protocolVersion) {
return protocolVersion > 4.2
}

function shouldUseShowIndexes (protocolVersion) {
return protocolVersion > 4.2
}
})