Skip to content

Commit 74916f2

Browse files
authored
test(NODE-6098): enable unified valid fail tests (#4181)
1 parent 357ca08 commit 74916f2

17 files changed

+476
-134
lines changed

test/integration/unified-test-format/unified_test_format.spec.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ const filter: TestFilter = ({ description }) => {
4141
return false;
4242
};
4343

44-
describe('Unified test format runner', function unifiedTestRunner() {
44+
describe('Unified test format runner (valid-pass)', function unifiedTestRunner() {
4545
// Valid tests that should pass
4646
runUnifiedSuite(loadSpecTests('unified-test-format/valid-pass'), filter);
4747
});
48+
49+
describe('Unified test format runner (valid-fail)', function unifiedTestRunner() {
50+
runUnifiedSuite(loadSpecTests('unified-test-format/valid-fail'), () => false, true);
51+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"description": "entity-findCursor-malformed",
3+
"schemaVersion": "1.3",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0"
8+
}
9+
},
10+
{
11+
"database": {
12+
"id": "database0",
13+
"client": "client0",
14+
"databaseName": "database0Name"
15+
}
16+
},
17+
{
18+
"collection": {
19+
"id": "collection0",
20+
"database": "database0",
21+
"collectionName": "coll0"
22+
}
23+
}
24+
],
25+
"initialData": [
26+
{
27+
"databaseName": "database0Name",
28+
"collectionName": "coll0",
29+
"documents": []
30+
}
31+
],
32+
"tests": [
33+
{
34+
"description": "createFindCursor fails if filter is not specified",
35+
"operations": [
36+
{
37+
"name": "createFindCursor",
38+
"object": "collection0",
39+
"saveResultAsEntity": "cursor0"
40+
}
41+
]
42+
}
43+
]
44+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This test is split out into a separate file to accommodate drivers that validate operation structure while decoding
2+
# from JSON/YML. Such drivers fail to decode any files containing invalid operations. Combining this test in a file
3+
# with other entity-findCursor valid-fail tests, which test failures that occur during test execution, would prevent
4+
# such drivers from decoding the file and running any of the tests.
5+
description: entity-findCursor-malformed
6+
7+
schemaVersion: '1.3'
8+
9+
createEntities:
10+
- client:
11+
id: &client0 client0
12+
- database:
13+
id: &database0 database0
14+
client: *client0
15+
databaseName: &database0Name database0Name
16+
- collection:
17+
id: &collection0 collection0
18+
database: *database0
19+
collectionName: &collection0Name coll0
20+
21+
initialData:
22+
- databaseName: *database0Name
23+
collectionName: *collection0Name
24+
documents: []
25+
26+
tests:
27+
- description: createFindCursor fails if filter is not specified
28+
operations:
29+
- name: createFindCursor
30+
object: *collection0
31+
saveResultAsEntity: &cursor0 cursor0
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"description": "entity-findCursor",
3+
"schemaVersion": "1.3",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0"
8+
}
9+
},
10+
{
11+
"database": {
12+
"id": "database0",
13+
"client": "client0",
14+
"databaseName": "database0Name"
15+
}
16+
},
17+
{
18+
"collection": {
19+
"id": "collection0",
20+
"database": "database0",
21+
"collectionName": "coll0"
22+
}
23+
}
24+
],
25+
"initialData": [
26+
{
27+
"databaseName": "database0Name",
28+
"collectionName": "coll0",
29+
"documents": []
30+
}
31+
],
32+
"tests": [
33+
{
34+
"description": "iterateUntilDocumentOrError fails if it references a nonexistent entity",
35+
"operations": [
36+
{
37+
"name": "iterateUntilDocumentOrError",
38+
"object": "cursor0"
39+
}
40+
]
41+
},
42+
{
43+
"description": "close fails if it references a nonexistent entity",
44+
"operations": [
45+
{
46+
"name": "close",
47+
"object": "cursor0"
48+
}
49+
]
50+
}
51+
]
52+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
description: entity-findCursor
2+
3+
schemaVersion: '1.3'
4+
5+
createEntities:
6+
- client:
7+
id: &client0 client0
8+
- database:
9+
id: &database0 database0
10+
client: *client0
11+
databaseName: &database0Name database0Name
12+
- collection:
13+
id: &collection0 collection0
14+
database: *database0
15+
collectionName: &collection0Name coll0
16+
17+
initialData:
18+
- databaseName: *database0Name
19+
collectionName: *collection0Name
20+
documents: []
21+
22+
tests:
23+
- description: iterateUntilDocumentOrError fails if it references a nonexistent entity
24+
operations:
25+
- name: iterateUntilDocumentOrError
26+
object: cursor0
27+
28+
- description: close fails if it references a nonexistent entity
29+
operations:
30+
- name: close
31+
object: cursor0
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"description": "ignoreResultAndError-malformed",
3+
"schemaVersion": "1.3",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"useMultipleMongoses": true
9+
}
10+
},
11+
{
12+
"database": {
13+
"id": "database0",
14+
"client": "client0",
15+
"databaseName": "database0Name"
16+
}
17+
},
18+
{
19+
"collection": {
20+
"id": "collection0",
21+
"database": "database0",
22+
"collectionName": "coll0"
23+
}
24+
}
25+
],
26+
"initialData": [
27+
{
28+
"collectionName": "coll0",
29+
"databaseName": "database0Name",
30+
"documents": []
31+
}
32+
],
33+
"tests": [
34+
{
35+
"description": "malformed operation fails if ignoreResultAndError is true",
36+
"operations": [
37+
{
38+
"name": "insertOne",
39+
"object": "collection0",
40+
"arguments": {
41+
"foo": "bar"
42+
},
43+
"ignoreResultAndError": true
44+
}
45+
]
46+
}
47+
]
48+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This test is split out into a separate file to accommodate drivers that validate operation structure while decoding
2+
# from JSON/YML. Such drivers fail to decode any files containing invalid operations. Combining this test in a file
3+
# with other ignoreResultAndError valid-fail tests, which test failures that occur during test execution, would prevent
4+
# such drivers from decoding the file and running any of the tests.
5+
description: ignoreResultAndError-malformed
6+
7+
schemaVersion: '1.3'
8+
9+
createEntities:
10+
- client:
11+
id: &client0 client0
12+
useMultipleMongoses: true
13+
- database:
14+
id: &database0 database0
15+
client: *client0
16+
databaseName: &database0Name database0Name
17+
- collection:
18+
id: &collection0 collection0
19+
database: *database0
20+
collectionName: &collection0Name coll0
21+
22+
initialData:
23+
- collectionName: *collection0Name
24+
databaseName: *database0Name
25+
documents: []
26+
27+
tests:
28+
- description: malformed operation fails if ignoreResultAndError is true
29+
operations:
30+
- name: insertOne
31+
object: *collection0
32+
arguments:
33+
foo: bar
34+
ignoreResultAndError: true

test/spec/unified-test-format/valid-fail/ignoreResultAndError.json

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@
5454
"ignoreResultAndError": false
5555
}
5656
]
57-
},
58-
{
59-
"description": "malformed operation fails if ignoreResultAndError is true",
60-
"operations": [
61-
{
62-
"name": "insertOne",
63-
"object": "collection0",
64-
"arguments": {
65-
"foo": "bar"
66-
},
67-
"ignoreResultAndError": true
68-
}
69-
]
7057
}
7158
]
7259
}

test/spec/unified-test-format/valid-fail/ignoreResultAndError.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,3 @@ tests:
3333
# Insert the same document to force a DuplicateKey error.
3434
document: *insertDocument
3535
ignoreResultAndError: false
36-
37-
- description: malformed operation fails if ignoreResultAndError is true
38-
operations:
39-
- name: insertOne
40-
object: *collection0
41-
arguments:
42-
foo: bar
43-
ignoreResultAndError: true
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"description": "operation-unsupported",
3+
"schemaVersion": "1.0",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0"
8+
}
9+
}
10+
],
11+
"tests": [
12+
{
13+
"description": "Unsupported operation",
14+
"operations": [
15+
{
16+
"name": "unsupportedOperation",
17+
"object": "client0"
18+
}
19+
]
20+
}
21+
]
22+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description: "operation-unsupported"
2+
3+
schemaVersion: "1.0"
4+
5+
createEntities:
6+
- client:
7+
id: &client0 client0
8+
9+
tests:
10+
- description: "Unsupported operation"
11+
operations:
12+
- name: unsupportedOperation
13+
object: *client0

0 commit comments

Comments
 (0)