Skip to content

Commit 059f49a

Browse files
committed
Moving some Type and Transaction ITs to Testkit
See neo4j-drivers/testkit#90
1 parent 005f63b commit 059f49a

File tree

2 files changed

+1
-191
lines changed

2 files changed

+1
-191
lines changed

test/transaction.test.js

Lines changed: 1 addition & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,6 @@ describe('#integration transaction', () => {
188188
)
189189
}, 60000)
190190

191-
it('should handle when committing when another query fails', async () => {
192-
// When
193-
const tx = session.beginTransaction()
194-
195-
await expectAsync(tx.run('CREATE (:TXNode1)')).toBeResolved()
196-
await expectAsync(tx.run('THIS IS NOT CYHER')).toBeRejectedWith(
197-
jasmine.objectContaining({
198-
message: jasmine.stringMatching(/Invalid input/)
199-
})
200-
)
201-
await expectAsync(tx.commit()).toBeRejectedWith(
202-
jasmine.objectContaining({
203-
message: jasmine.stringMatching(/Cannot commit this transaction/)
204-
})
205-
)
206-
}, 60000)
207-
208191
it('should handle rollbacks', done => {
209192
const tx = session.beginTransaction()
210193
tx.run('CREATE (:TXNode1)')
@@ -232,147 +215,6 @@ describe('#integration transaction', () => {
232215
.catch(console.log)
233216
}, 60000)
234217

235-
it('should fail when committing on a rolled back query', async () => {
236-
const tx = session.beginTransaction()
237-
await tx.run('CREATE (:TXNode1)')
238-
await tx.rollback()
239-
240-
await expectAsync(tx.commit()).toBeRejectedWith(
241-
jasmine.objectContaining({
242-
message: jasmine.stringMatching(
243-
/Cannot commit this transaction, because .* rolled back/
244-
)
245-
})
246-
)
247-
}, 60000)
248-
249-
it('should fail when running on a rolled back transaction', async () => {
250-
const tx = session.beginTransaction()
251-
await tx.run('CREATE (:TXNode1)')
252-
await tx.rollback()
253-
254-
await expectAsync(tx.run('RETURN 42')).toBeRejectedWith(
255-
jasmine.objectContaining({
256-
message: jasmine.stringMatching(
257-
/Cannot run query in this transaction, because .* rolled back/
258-
)
259-
})
260-
)
261-
}, 60000)
262-
263-
it('should fail running when a previous query failed', async () => {
264-
const tx = session.beginTransaction()
265-
266-
await expectAsync(tx.run('THIS IS NOT CYPHER')).toBeRejectedWith(
267-
jasmine.stringMatching(/Invalid input/)
268-
)
269-
270-
await expectAsync(tx.run('RETURN 42')).toBeRejectedWith(
271-
jasmine.objectContaining({
272-
message: jasmine.stringMatching(
273-
/Cannot run query in this transaction, because .* an error/
274-
)
275-
})
276-
)
277-
await tx.rollback()
278-
}, 60000)
279-
280-
it('should fail when trying to roll back a rolled back transaction', async () => {
281-
const tx = session.beginTransaction()
282-
await tx.run('CREATE (:TXNode1)')
283-
await tx.rollback()
284-
285-
await expectAsync(tx.rollback()).toBeRejectedWith(
286-
jasmine.objectContaining({
287-
message: jasmine.stringMatching(
288-
/Cannot rollback this transaction, because .* rolled back/
289-
)
290-
})
291-
)
292-
}, 60000)
293-
294-
it('should provide bookmark on commit', done => {
295-
// new session without initial bookmark
296-
session = driver.session()
297-
expect(session.lastBookmark()).toEqual([])
298-
299-
const tx = session.beginTransaction()
300-
tx.run('CREATE (:TXNode1)')
301-
.then(() => {
302-
tx.run('CREATE (:TXNode2)')
303-
.then(() => {
304-
tx.commit().then(() => {
305-
expectValidLastBookmark(session)
306-
done()
307-
})
308-
})
309-
.catch(console.log)
310-
})
311-
.catch(console.log)
312-
}, 60000)
313-
314-
it('should have bookmark when tx is rolled back', done => {
315-
// new session without initial bookmark
316-
session = driver.session()
317-
expect(session.lastBookmark()).toEqual([])
318-
319-
const tx1 = session.beginTransaction()
320-
tx1.run('CREATE ()').then(() => {
321-
tx1.commit().then(() => {
322-
expectValidLastBookmark(session)
323-
const bookmarkBefore = session.lastBookmark()
324-
325-
const tx2 = session.beginTransaction()
326-
tx2.run('CREATE ()').then(() => {
327-
tx2.rollback().then(() => {
328-
expectValidLastBookmark(session)
329-
const bookmarkAfter = session.lastBookmark()
330-
expect(bookmarkAfter).toEqual(bookmarkBefore)
331-
332-
const tx3 = session.beginTransaction()
333-
tx3.run('CREATE ()').then(() => {
334-
tx3.commit().then(() => {
335-
expectValidLastBookmark(session)
336-
done()
337-
})
338-
})
339-
})
340-
})
341-
})
342-
})
343-
}, 60000)
344-
345-
it('should have no bookmark when tx fails', done => {
346-
// new session without initial bookmark
347-
session = driver.session()
348-
expect(session.lastBookmark()).toEqual([])
349-
350-
const tx1 = session.beginTransaction()
351-
352-
tx1.run('CREATE ()').then(() => {
353-
tx1.commit().then(() => {
354-
expectValidLastBookmark(session)
355-
const bookmarkBefore = session.lastBookmark()
356-
357-
const tx2 = session.beginTransaction()
358-
359-
tx2.run('RETURN').catch(error => {
360-
expectSyntaxError(error)
361-
const bookmarkAfter = session.lastBookmark()
362-
expect(bookmarkAfter).toEqual(bookmarkBefore)
363-
364-
const tx3 = session.beginTransaction()
365-
tx3.run('CREATE ()').then(() => {
366-
tx3.commit().then(() => {
367-
expectValidLastBookmark(session)
368-
done()
369-
})
370-
})
371-
})
372-
})
373-
})
374-
}, 60000)
375-
376218
it('should throw when provided string (bookmark) parameter', () => {
377219
expect(() => session.beginTransaction('bookmark')).toThrowError(TypeError)
378220
}, 60000)
@@ -399,11 +241,10 @@ describe('#integration transaction', () => {
399241
})
400242
const tx2 = session2.beginTransaction()
401243
tx2.run('CREATE ()').catch(error => {
402-
const message = error.message
403244
// Checking message text on <= 4.0, check code for >= 4.1
404245
expect(
405246
error.message.includes('not up to the requested version') ||
406-
error.code == 'Neo.ClientError.Transaction.InvalidBookmark'
247+
error.code === 'Neo.ClientError.Transaction.InvalidBookmark'
407248
).toBeTruthy()
408249
done()
409250
})

test/types.test.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ describe('#integration floating point values', () => {
3535
})
3636

3737
describe('#integration integer values', () => {
38-
it('should support integer 1 ', testValue(neo4j.int(1)))
39-
it('should support integer 0 ', testValue(neo4j.int(0)))
40-
it('should support integer -1 ', testValue(neo4j.int(-1)))
4138
it(
4239
'should support integer larger than JS Numbers can model',
4340
testValue(neo4j.int('0x7fffffffffffffff'))
@@ -50,31 +47,17 @@ describe('#integration integer values', () => {
5047

5148
describe('#integration boolean values', () => {
5249
it('should support true ', testValue(true))
53-
it('should support false ', testValue(false))
5450
})
5551

5652
describe('#integration string values', () => {
57-
it('should support empty string ', testValue(''))
5853
it('should support simple string ', testValue('abcdefghijklmnopqrstuvwxyz'))
59-
it(
60-
'should support awesome string ',
61-
testValue('All makt åt Tengil, vår befriare.')
62-
)
63-
it('should support long string', testValue('*'.repeat(10000)))
6454
})
6555

6656
describe('#integration list values', () => {
6757
it('should support empty lists ', testValue([]))
6858
it('should support sparse lists ', testValue([undefined, 4], [null, 4]))
69-
it('should support float lists ', testValue([1, 2, 3]))
70-
it('should support boolean lists ', testValue([true, false]))
71-
it('should support string lists ', testValue(['', 'hello!']))
7259
it('should support list lists ', testValue([[], [1, 2, 3]]))
7360
it('should support map lists ', testValue([{}, { a: 12 }]))
74-
it(
75-
'should support long list',
76-
testValue(Array.from({ length: 1000 }, (v, i) => i))
77-
)
7861
})
7962

8063
describe('#integration map values', () => {
@@ -83,20 +66,6 @@ describe('#integration map values', () => {
8366
'should support basic maps ',
8467
testValue({ a: 1, b: {}, c: [], d: { e: 1 } })
8568
)
86-
it(
87-
'should support sparse maps ',
88-
testValue({ foo: undefined, bar: null }, { bar: null })
89-
)
90-
91-
function longMap () {
92-
const map = {}
93-
for (let i = 0; i < 1000; i++) {
94-
map['key' + i] = i
95-
}
96-
return map
97-
}
98-
99-
it('should support long maps', testValue(longMap()))
10069
})
10170

10271
describe('#integration node values', () => {

0 commit comments

Comments
 (0)