From 8300bdcd4efdb6b2c3b871823eb2eb3de03bbdcb Mon Sep 17 00:00:00 2001 From: Antonio Barcelos Date: Wed, 21 Apr 2021 20:46:15 +0200 Subject: [PATCH] Moving some Type and Transaction ITs to Testkit See https://github.com/neo4j-drivers/testkit/pull/90 --- test/transaction.test.js | 161 +-------------------------------------- test/types.test.js | 31 -------- 2 files changed, 1 insertion(+), 191 deletions(-) diff --git a/test/transaction.test.js b/test/transaction.test.js index b51ab35a1..1f98f8131 100644 --- a/test/transaction.test.js +++ b/test/transaction.test.js @@ -188,23 +188,6 @@ describe('#integration transaction', () => { ) }, 60000) - it('should handle when committing when another query fails', async () => { - // When - const tx = session.beginTransaction() - - await expectAsync(tx.run('CREATE (:TXNode1)')).toBeResolved() - await expectAsync(tx.run('THIS IS NOT CYHER')).toBeRejectedWith( - jasmine.objectContaining({ - message: jasmine.stringMatching(/Invalid input/) - }) - ) - await expectAsync(tx.commit()).toBeRejectedWith( - jasmine.objectContaining({ - message: jasmine.stringMatching(/Cannot commit this transaction/) - }) - ) - }, 60000) - it('should handle rollbacks', done => { const tx = session.beginTransaction() tx.run('CREATE (:TXNode1)') @@ -232,147 +215,6 @@ describe('#integration transaction', () => { .catch(console.log) }, 60000) - it('should fail when committing on a rolled back query', async () => { - const tx = session.beginTransaction() - await tx.run('CREATE (:TXNode1)') - await tx.rollback() - - await expectAsync(tx.commit()).toBeRejectedWith( - jasmine.objectContaining({ - message: jasmine.stringMatching( - /Cannot commit this transaction, because .* rolled back/ - ) - }) - ) - }, 60000) - - it('should fail when running on a rolled back transaction', async () => { - const tx = session.beginTransaction() - await tx.run('CREATE (:TXNode1)') - await tx.rollback() - - await expectAsync(tx.run('RETURN 42')).toBeRejectedWith( - jasmine.objectContaining({ - message: jasmine.stringMatching( - /Cannot run query in this transaction, because .* rolled back/ - ) - }) - ) - }, 60000) - - it('should fail running when a previous query failed', async () => { - const tx = session.beginTransaction() - - await expectAsync(tx.run('THIS IS NOT CYPHER')).toBeRejectedWith( - jasmine.stringMatching(/Invalid input/) - ) - - await expectAsync(tx.run('RETURN 42')).toBeRejectedWith( - jasmine.objectContaining({ - message: jasmine.stringMatching( - /Cannot run query in this transaction, because .* an error/ - ) - }) - ) - await tx.rollback() - }, 60000) - - it('should fail when trying to roll back a rolled back transaction', async () => { - const tx = session.beginTransaction() - await tx.run('CREATE (:TXNode1)') - await tx.rollback() - - await expectAsync(tx.rollback()).toBeRejectedWith( - jasmine.objectContaining({ - message: jasmine.stringMatching( - /Cannot rollback this transaction, because .* rolled back/ - ) - }) - ) - }, 60000) - - it('should provide bookmark on commit', done => { - // new session without initial bookmark - session = driver.session() - expect(session.lastBookmark()).toEqual([]) - - const tx = session.beginTransaction() - tx.run('CREATE (:TXNode1)') - .then(() => { - tx.run('CREATE (:TXNode2)') - .then(() => { - tx.commit().then(() => { - expectValidLastBookmark(session) - done() - }) - }) - .catch(console.log) - }) - .catch(console.log) - }, 60000) - - it('should have bookmark when tx is rolled back', done => { - // new session without initial bookmark - session = driver.session() - expect(session.lastBookmark()).toEqual([]) - - const tx1 = session.beginTransaction() - tx1.run('CREATE ()').then(() => { - tx1.commit().then(() => { - expectValidLastBookmark(session) - const bookmarkBefore = session.lastBookmark() - - const tx2 = session.beginTransaction() - tx2.run('CREATE ()').then(() => { - tx2.rollback().then(() => { - expectValidLastBookmark(session) - const bookmarkAfter = session.lastBookmark() - expect(bookmarkAfter).toEqual(bookmarkBefore) - - const tx3 = session.beginTransaction() - tx3.run('CREATE ()').then(() => { - tx3.commit().then(() => { - expectValidLastBookmark(session) - done() - }) - }) - }) - }) - }) - }) - }, 60000) - - it('should have no bookmark when tx fails', done => { - // new session without initial bookmark - session = driver.session() - expect(session.lastBookmark()).toEqual([]) - - const tx1 = session.beginTransaction() - - tx1.run('CREATE ()').then(() => { - tx1.commit().then(() => { - expectValidLastBookmark(session) - const bookmarkBefore = session.lastBookmark() - - const tx2 = session.beginTransaction() - - tx2.run('RETURN').catch(error => { - expectSyntaxError(error) - const bookmarkAfter = session.lastBookmark() - expect(bookmarkAfter).toEqual(bookmarkBefore) - - const tx3 = session.beginTransaction() - tx3.run('CREATE ()').then(() => { - tx3.commit().then(() => { - expectValidLastBookmark(session) - done() - }) - }) - }) - }) - }) - }, 60000) - it('should throw when provided string (bookmark) parameter', () => { expect(() => session.beginTransaction('bookmark')).toThrowError(TypeError) }, 60000) @@ -399,11 +241,10 @@ describe('#integration transaction', () => { }) const tx2 = session2.beginTransaction() tx2.run('CREATE ()').catch(error => { - const message = error.message // Checking message text on <= 4.0, check code for >= 4.1 expect( error.message.includes('not up to the requested version') || - error.code == 'Neo.ClientError.Transaction.InvalidBookmark' + error.code === 'Neo.ClientError.Transaction.InvalidBookmark' ).toBeTruthy() done() }) diff --git a/test/types.test.js b/test/types.test.js index 7a30a4d13..ea2c23d29 100644 --- a/test/types.test.js +++ b/test/types.test.js @@ -35,9 +35,6 @@ describe('#integration floating point values', () => { }) describe('#integration integer values', () => { - it('should support integer 1 ', testValue(neo4j.int(1))) - it('should support integer 0 ', testValue(neo4j.int(0))) - it('should support integer -1 ', testValue(neo4j.int(-1))) it( 'should support integer larger than JS Numbers can model', testValue(neo4j.int('0x7fffffffffffffff')) @@ -50,31 +47,17 @@ describe('#integration integer values', () => { describe('#integration boolean values', () => { it('should support true ', testValue(true)) - it('should support false ', testValue(false)) }) describe('#integration string values', () => { - it('should support empty string ', testValue('')) it('should support simple string ', testValue('abcdefghijklmnopqrstuvwxyz')) - it( - 'should support awesome string ', - testValue('All makt åt Tengil, vår befriare.') - ) - it('should support long string', testValue('*'.repeat(10000))) }) describe('#integration list values', () => { it('should support empty lists ', testValue([])) it('should support sparse lists ', testValue([undefined, 4], [null, 4])) - it('should support float lists ', testValue([1, 2, 3])) - it('should support boolean lists ', testValue([true, false])) - it('should support string lists ', testValue(['', 'hello!'])) it('should support list lists ', testValue([[], [1, 2, 3]])) it('should support map lists ', testValue([{}, { a: 12 }])) - it( - 'should support long list', - testValue(Array.from({ length: 1000 }, (v, i) => i)) - ) }) describe('#integration map values', () => { @@ -83,20 +66,6 @@ describe('#integration map values', () => { 'should support basic maps ', testValue({ a: 1, b: {}, c: [], d: { e: 1 } }) ) - it( - 'should support sparse maps ', - testValue({ foo: undefined, bar: null }, { bar: null }) - ) - - function longMap () { - const map = {} - for (let i = 0; i < 1000; i++) { - map['key' + i] = i - } - return map - } - - it('should support long maps', testValue(longMap())) }) describe('#integration node values', () => {