Skip to content

Commit ad5c9e5

Browse files
committed
testkit: Enable routing tests
Treating the messages SessionBeginTransaction and TransactionCommit, and fix the session access mode param.
1 parent 6218f36 commit ad5c9e5

File tree

4 files changed

+189
-82
lines changed

4 files changed

+189
-82
lines changed

testkit-backend/context.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
export default class Context {
2+
constructor () {
3+
this._id = 0
4+
this._drivers = {}
5+
this._sessions = {}
6+
this._txs = {}
7+
this._resultObservers = {}
8+
this._errors = {}
9+
}
10+
11+
addDriver (driver) {
12+
return this._add(this._drivers, driver)
13+
}
14+
15+
addSession (session) {
16+
return this._add(this._sessions, session)
17+
}
18+
19+
addTx (tx, sessionId, resolve, reject) {
20+
const id = this._add(this._txs, {
21+
sessionId,
22+
tx,
23+
resolve,
24+
reject
25+
})
26+
this._txs[id].id = id
27+
return id
28+
}
29+
30+
addError (error) {
31+
return this._add(this._errors, error)
32+
}
33+
34+
addResultObserver (observer) {
35+
return this._add(this._resultObservers, observer)
36+
}
37+
38+
getDriver (id) {
39+
return this._drivers[id]
40+
}
41+
42+
getSession (id) {
43+
console.log(this._sessions)
44+
return this._sessions[id]
45+
}
46+
47+
getTx (id) {
48+
return this._txs[id]
49+
}
50+
51+
getResultObserver (id) {
52+
return this._resultObservers[id]
53+
}
54+
55+
getError (id) {
56+
return this._errors[id]
57+
}
58+
59+
removeDriver (id) {
60+
delete this._drivers[id]
61+
}
62+
63+
removeSession (id) {
64+
delete this._sessions[id]
65+
}
66+
67+
removeTx (id) {
68+
delete this._txs[id]
69+
}
70+
71+
removeResultObserver (id) {
72+
delete this._resultObservers[id]
73+
}
74+
75+
getResultObserversBySessionId (sessionId) {
76+
return Object.values(this._resultObservers).filter(
77+
obs => obs.sessionId === sessionId
78+
)
79+
}
80+
81+
getTxsBySessionId (sessionId) {
82+
return Object.values(this._txs).filter(tx => tx.sessionId === sessionId)
83+
}
84+
85+
_add (map, object) {
86+
this._id++
87+
map[this._id] = object
88+
return this._id
89+
}
90+
}

testkit-backend/cypher-native-binders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const neo4j = require('neo4j-driver')
1+
import neo4j from 'neo4j-driver'
22

33
export function valueResponse (name, value) {
44
return { name: name, data: { value: value } }

0 commit comments

Comments
 (0)