Skip to content

Commit 009d9e4

Browse files
Peter Wilhelmsson2hdddg
authored andcommitted
Plan/Profile fixes for neo4j server 4.1
Format of operator type has changed in server 4.1. Fix so that tests accepts old and new format. Also remove obsolete index/constraint syntax as preparation.
1 parent b251e28 commit 009d9e4

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

test/rx/summary.test.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ describe('#integration-rx summary', () => {
571571
.toPromise()
572572
expect(summary).toBeDefined()
573573
expect(summary.hasPlan()).toBeTruthy()
574-
expect(summary.plan.operatorType).toBe('ProduceResults')
574+
expect(summary.plan.operatorType).toContain('ProduceResults')
575575
expect(summary.plan.identifiers).toEqual(['n'])
576576
expect(summary.hasProfile()).toBeFalsy()
577577
expect(summary.profile).toBeFalsy()
@@ -592,10 +592,10 @@ describe('#integration-rx summary', () => {
592592
.toPromise()
593593
expect(summary).toBeDefined()
594594
expect(summary.hasPlan()).toBeTruthy()
595-
expect(summary.plan.operatorType).toBe('ProduceResults')
595+
expect(summary.plan.operatorType).toContain('ProduceResults')
596596
expect(summary.plan.identifiers).toEqual(['n'])
597597
expect(summary.hasProfile()).toBeTruthy()
598-
expect(summary.profile.operatorType).toBe('ProduceResults')
598+
expect(summary.profile.operatorType).toContain('ProduceResults')
599599
expect(summary.profile.identifiers).toEqual(['n'])
600600
}
601601

@@ -727,25 +727,18 @@ describe('#integration-rx summary', () => {
727727
}
728728

729729
async function dropConstraintsAndIndices (driver) {
730-
function getName (record) {
731-
const obj = record.toObject()
732-
const name = obj.description || obj.name
733-
if (!name) {
734-
throw new Error('unable to identify name of the constraint/index')
735-
}
736-
return name
737-
}
738-
739730
const session = driver.session()
740731
try {
741732
const constraints = await session.run('CALL db.constraints()')
742733
for (let i = 0; i < constraints.records.length; i++) {
743-
await session.run(`DROP ${getName(constraints.records[i])}`)
734+
const name = constraints.records[i].toObject().name
735+
await session.run('DROP CONSTRAINT ' + name) // ${getName(constraints.records[i])}`)
744736
}
745737

746738
const indices = await session.run('CALL db.indexes()')
747739
for (let i = 0; i < indices.records.length; i++) {
748-
await session.run(`DROP INDEX ${getName(indices.records[i])}`)
740+
const name = indices.records[i].toObject().name
741+
await session.run('DROP INDEX ' + name) // ${getName(constraints.records[i])}`)
749742
}
750743
} finally {
751744
await session.close()

test/session.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ describe('#integration session', () => {
688688
})
689689

690690
it('should not commit already committed write transaction', done => {
691-
const resultPromise = session.readTransaction(tx => {
691+
const resultPromise = session.writeTransaction(tx => {
692692
return new Promise((resolve, reject) => {
693693
tx.run('CREATE (n:Node {id: 42}) RETURN n.id AS answer')
694694
.then(result => {
@@ -747,7 +747,7 @@ describe('#integration session', () => {
747747

748748
it('should not commit rolled back write transaction', done => {
749749
const bookmarkBefore = session.lastBookmark()
750-
const resultPromise = session.readTransaction(tx => {
750+
const resultPromise = session.writeTransaction(tx => {
751751
return new Promise((resolve, reject) => {
752752
tx.run('CREATE (n:Node {id: 42}) RETURN n.id AS answer')
753753
.then(result => {

0 commit comments

Comments
 (0)