Skip to content

Commit 18b359e

Browse files
authored
test(NODE-3738): fix uri spec runner (#3117)
1 parent c81c506 commit 18b359e

File tree

8 files changed

+449
-167
lines changed

8 files changed

+449
-167
lines changed

test/integration/uri-options/uri_options.spec.test.js

Lines changed: 0 additions & 73 deletions
This file was deleted.

test/spec/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ const path = require('path');
33
const fs = require('fs');
44
const { EJSON } = require('bson');
55

6+
function hasDuplicates(testArray) {
7+
const testNames = testArray.map(test => test.description);
8+
const testNameSet = new Set(testNames);
9+
return testNameSet.size !== testNames.length;
10+
}
11+
612
/**
713
* Given spec test folder names, loads the corresponding JSON
814
*
@@ -12,13 +18,23 @@ const { EJSON } = require('bson');
1218
function loadSpecTests(...args) {
1319
const specPath = path.resolve(...[__dirname].concat(args));
1420

15-
return fs
21+
const suites = fs
1622
.readdirSync(specPath)
1723
.filter(x => x.includes('.json'))
1824
.map(x => ({
1925
...EJSON.parse(fs.readFileSync(path.join(specPath, x)), { relaxed: true }),
2026
name: path.basename(x, '.json')
2127
}));
28+
29+
for (const suite of suites) {
30+
if (suite.tests && hasDuplicates(suite.tests)) {
31+
throw new Error(
32+
`Failed to load suite ${suite.name} because it contains duplicate test cases`
33+
);
34+
}
35+
}
36+
37+
return suites;
2238
}
2339

2440
module.exports = {

test/spec/uri-options/tls-options.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@
4444
"tlsAllowInvalidCertificates": true
4545
}
4646
},
47-
{
48-
"description": "Invalid tlsAllowInvalidCertificates causes a warning",
49-
"uri": "mongodb://example.com/?tlsAllowInvalidCertificates=invalid",
50-
"valid": true,
51-
"warning": true,
52-
"hosts": null,
53-
"auth": null,
54-
"options": {}
55-
},
5647
{
5748
"description": "tlsAllowInvalidHostnames is parsed correctly",
5849
"uri": "mongodb://example.com/?tlsAllowInvalidHostnames=true",

test/spec/uri-options/tls-options.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ tests:
3636
auth: ~
3737
options:
3838
tlsAllowInvalidCertificates: true
39-
-
40-
description: "Invalid tlsAllowInvalidCertificates causes a warning"
41-
uri: "mongodb://example.com/?tlsAllowInvalidCertificates=invalid"
42-
valid: true
43-
warning: true
44-
hosts: ~
45-
auth: ~
46-
options: {}
4739
-
4840
description: "tlsAllowInvalidHostnames is parsed correctly"
4941
uri: "mongodb://example.com/?tlsAllowInvalidHostnames=true"

0 commit comments

Comments
 (0)