Skip to content

Commit 50987b1

Browse files
committed
Fix flaky http driver test
It executes same query that returns paths using bolt and http. Results are then compared and expected to be the same. Previously used query was not entirely deterministic and could return different results for subsequent executions. This commit fixes the problem by making var-length queries use fixed start node. Also added logging of query when expectation fails.
1 parent 54a0641 commit 50987b1

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

test/internal/http/http-driver.test.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ describe('http driver', () => {
166166
`MATCH p=((:Person2)-[:KNOWS]-(:Person1)) RETURN p`,
167167
`MATCH p=((:Person3)-[:KNOWS]-(:Person4)-[:LIKES]-(:Person5)) RETURN p`,
168168
`MATCH p=((:Person3)-[*]-(:Person6)) RETURN p`,
169-
`MATCH p=(()-[*]-()) RETURN p`,
169+
`MATCH p=((:Person1)-[*]-()) RETURN p`,
170+
`MATCH p=((:Person3)-[*]-()) RETURN p`,
171+
`MATCH p=((:Person6)-[*]-()) RETURN p`
170172
], done);
171173
});
172174
});
@@ -501,28 +503,29 @@ describe('http driver', () => {
501503
const boltResultsPromise = Promise.all(values.map(value => runQueryAndGetResults(query, {value: value}, boltDriver)));
502504
const httpResultsPromise = Promise.all(values.map(value => runQueryAndGetResults(query, {value: value}, httpDriver)));
503505

504-
assertResultsAreEqual(boltResultsPromise, httpResultsPromise, values.length, done);
506+
assertResultsAreEqual(boltResultsPromise, httpResultsPromise, values, done);
505507
}
506508

507509
function testReceivingOfResults(queries, done) {
508510
const boltResultsPromise = Promise.all(queries.map(query => runQueryAndGetResults(query, {}, boltDriver)));
509511
const httpResultsPromise = Promise.all(queries.map(query => runQueryAndGetResults(query, {}, httpDriver)));
510512

511-
assertResultsAreEqual(boltResultsPromise, httpResultsPromise, queries.length, done);
513+
assertResultsAreEqual(boltResultsPromise, httpResultsPromise, queries, done);
512514
}
513515

514-
function assertResultsAreEqual(boltResultsPromise, httpResultsPromise, expectedLength, done) {
516+
function assertResultsAreEqual(boltResultsPromise, httpResultsPromise, testInputs, done) {
515517
Promise.all([boltResultsPromise, httpResultsPromise]).then(results => {
516518
const boltResults = results[0];
517519
const httpResults = results[1];
518520

519-
expect(boltResults.length).toEqual(expectedLength);
520-
expect(httpResults.length).toEqual(expectedLength);
521+
expect(boltResults.length).toEqual(testInputs.length);
522+
expect(httpResults.length).toEqual(testInputs.length);
521523

522-
for (let i = 0; i < expectedLength; i++) {
524+
for (let i = 0; i < testInputs.length; i++) {
525+
const testInput = testInputs[i];
523526
const boltResultRow = boltResults[i];
524527
const httpResultRow = httpResults[i];
525-
expect(boltResultRow).toEqual(httpResultRow);
528+
expect(boltResultRow).toEqual(httpResultRow, 'Failed for: ' + JSON.stringify(testInput));
526529
}
527530

528531
done();

0 commit comments

Comments
 (0)