Skip to content

Commit 028c500

Browse files
committed
testkit-backend: Improve the skipTest mechanism
1 parent 06b9cc1 commit 028c500

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

testkit-backend/src/request-handlers.js

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

56
export function NewDriver (context, data, { writeResponse }) {
67
const {
@@ -16,7 +17,11 @@ export function NewDriver (context, data, { writeResponse }) {
1617
writeResponse('ResolverResolutionRequired', { id, address })
1718
})
1819
: undefined
19-
const driver = neo4j.driver(uri, authToken, { userAgent, resolver, useBigInt: true })
20+
const driver = neo4j.driver(uri, authToken, {
21+
userAgent,
22+
resolver,
23+
useBigInt: true
24+
})
2025
const id = context.addDriver(driver)
2126
writeResponse('Driver', { id })
2227
}
@@ -222,28 +227,10 @@ export function SessionWriteTransaction (context, data, wire) {
222227
}
223228

224229
export function StartTest (_, { testName }, wire) {
225-
if (
226-
testName.endsWith(
227-
'test_should_use_initial_router_for_discovery_when_others_unavailable'
228-
)
229-
) {
230-
console.warn(`>>> Skipping test ${testName}`)
231-
const reason =
232-
'Driver is failing trying to update the original routing server'
233-
wire.writeResponse('SkipTest', { reason })
234-
} else if (
235-
testName.endsWith(
236-
'test_should_successfully_check_if_support_for_multi_db_is_available'
237-
)
238-
) {
239-
console.warn(`>>> Skipping test ${testName}`)
240-
const reason =
241-
'Driver is creating a dedicated connection to check the MultiDBSupport'
242-
wire.writeResponse('SkipTest', { reason })
243-
} else {
244-
console.log(`>>> Starting test ${testName}`)
245-
wire.writeResponse('RunTest', null)
246-
}
230+
shouldRunTest(testName, {
231+
onRun: () => wire.writeResponse('RunTest', null),
232+
onSkip: reason => wire.writeResponse('SkipTest', { reason })
233+
})
247234
}
248235

249236
export function VerifyConnectivity (context, { driverId }, wire) {

testkit-backend/src/skipped-tests.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function ifEndsWith (suffix) {
2+
return testName => testName.endsWith(suffix)
3+
}
4+
5+
function skip (reason, predicate) {
6+
return { reason, predicate }
7+
}
8+
9+
const skippedTests = [
10+
skip(
11+
'Driver is failing trying to update the routing table using the original routing server',
12+
ifEndsWith(
13+
'test_should_use_initial_router_for_discovery_when_others_unavailable'
14+
)
15+
),
16+
skip(
17+
'Driver is creating a dedicated connection to check the MultiDBSupport',
18+
ifEndsWith(
19+
'test_should_successfully_check_if_support_for_multi_db_is_available'
20+
)
21+
)
22+
]
23+
24+
export function shouldRunTest (testName, { onRun, onSkip }) {
25+
const { reason } =
26+
skippedTests.find(({ predicate }) => predicate(testName)) || {}
27+
!reason ? onRun() : onSkip(reason)
28+
}

0 commit comments

Comments
 (0)