Skip to content

Commit dab5f81

Browse files
committed
Improve the driver import in the testkit-backend
1 parent 9fdf30e commit dab5f81

File tree

8 files changed

+21
-23
lines changed

8 files changed

+21
-23
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test": "lerna run test --stream",
1414
"start-neo4j": "lerna run start-neo4j --scope neo4j-driver",
1515
"stop-neo4j": "lerna run stop-neo4j --scope neo4j-driver",
16+
"start-testkit-backend": "lerna run start --scope testkit-backend --stream",
1617
"lerna": "lerna"
1718
}
1819
}

packages/testkit-backend/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
},
2525
"homepage": "https://github.com/neo4j/neo4j-javascript-driver#readme",
2626
"dependencies": {
27-
"neo4j": "file:../neo4j-driver"
27+
"neo4j-driver-lite": "4.4.0-dev",
28+
"neo4j-driver": "4.4.0-dev"
2829
},
2930
"devDependencies": {
3031
"esm": "^3.2.25"

packages/testkit-backend/src/cypher-native-binders.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import neo4j, { int } from 'neo4j'
1+
import neo4j from './neo4j'
22

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

packages/testkit-backend/src/neo4j.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import neo4jDriver from 'neo4j-driver'
2+
import neo4jDriverLite from 'neo4j-driver-lite'
3+
4+
const isLite = (process.env.TEST_DRIVER_LITE || 'False').toUpperCase() in ['TRUE', '1']
5+
const neo4j = isLite ? neo4jDriverLite : neo4jDriver
6+
7+
export default neo4j

packages/testkit-backend/src/request-handlers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import neo4j from 'neo4j'
1+
import neo4j from './neo4j'
22
import ResultObserver from './result-observer.js'
33
import { cypherToNative, nativeToCypher } from './cypher-native-binders.js'
44
import { shouldRunTest } from './skipped-tests'

packages/testkit-backend/src/result-observer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import neo4j from 'neo4j'
1+
import neo4j from './neo4j'
22

33
export default class ResultObserver {
44
constructor ({ sessionId, result }) {

testkit/backend.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Assumes driver and backend has been built.
44
Responsible for starting the test backend.
55
"""
6-
from common import DRIVER_REPO, run
7-
6+
from common import run_in_driver_repo
7+
import os
88

99
if __name__ == "__main__":
10-
run(["npm", "start"], cwd=DRIVER_REPO + "packages/testkit-backend")
10+
run_in_driver_repo(["npm", "run", "start-testkit-backend"], env=os.environ)

testkit/build.py

+5-16
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Executed in Javascript driver container.
33
Responsible for building driver and test backend.
44
"""
5+
from common import run, run_in_driver_repo, DRIVER_REPO
56
import os
6-
from common import run, run_in, run_in_driver_repo, is_lite, DRIVER_REPO
77

88

99
def copy_files_to_workdir():
@@ -13,27 +13,16 @@ def copy_files_to_workdir():
1313

1414

1515
def init_monorepo():
16-
run_in_driver_repo(["rm", "-fr", "node_modules"])
17-
run_in_driver_repo(["npm", "ci"])
16+
run_in_driver_repo(["rm", "-fr", "node_modules"], env=os.environ)
17+
run_in_driver_repo(["npm", "ci"], env=os.environ)
1818

1919

2020
def clean_and_build():
21-
run_in_driver_repo(["npm", "run", "clean"])
22-
run_in_driver_repo(["npm", "run", "build"])
23-
24-
25-
def build_testkit_backend():
26-
run_in_testkit_backend = run_in(
27-
cwd=DRIVER_REPO + "packages/testkit-backend/")
28-
run_in_testkit_backend(["rm", "-fr", "node_modules"])
29-
neo4jdriverPath = "neo4j@../neo4j-driver" if not is_lite()\
30-
else "neo4j@../neo4j-driver-lite"
31-
run_in_testkit_backend(["npm", "install", neo4jdriverPath])
32-
run_in_testkit_backend(["npm", "install"])
21+
run_in_driver_repo(["npm", "run", "clean"], env=os.environ)
22+
run_in_driver_repo(["npm", "run", "build"], env=os.environ)
3323

3424

3525
if __name__ == "__main__":
3626
copy_files_to_workdir()
3727
init_monorepo()
3828
clean_and_build()
39-
build_testkit_backend()

0 commit comments

Comments
 (0)