Skip to content

test(NODE-6098): enable unified valid fail tests #4181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ const filter: TestFilter = ({ description }) => {
return false;
};

describe('Unified test format runner', function unifiedTestRunner() {
describe('Unified test format runner (valid-pass)', function unifiedTestRunner() {
// Valid tests that should pass
runUnifiedSuite(loadSpecTests('unified-test-format/valid-pass'), filter);
});

describe('Unified test format runner (valid-fail)', function unifiedTestRunner() {
runUnifiedSuite(loadSpecTests('unified-test-format/valid-fail'), () => false, true);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"description": "entity-findCursor-malformed",
"schemaVersion": "1.3",
"createEntities": [
{
"client": {
"id": "client0"
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0Name"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "coll0"
}
}
],
"initialData": [
{
"databaseName": "database0Name",
"collectionName": "coll0",
"documents": []
}
],
"tests": [
{
"description": "createFindCursor fails if filter is not specified",
"operations": [
{
"name": "createFindCursor",
"object": "collection0",
"saveResultAsEntity": "cursor0"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This test is split out into a separate file to accommodate drivers that validate operation structure while decoding
# from JSON/YML. Such drivers fail to decode any files containing invalid operations. Combining this test in a file
# with other entity-findCursor valid-fail tests, which test failures that occur during test execution, would prevent
# such drivers from decoding the file and running any of the tests.
description: entity-findCursor-malformed

schemaVersion: '1.3'

createEntities:
- client:
id: &client0 client0
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name database0Name
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0

initialData:
- databaseName: *database0Name
collectionName: *collection0Name
documents: []

tests:
- description: createFindCursor fails if filter is not specified
operations:
- name: createFindCursor
object: *collection0
saveResultAsEntity: &cursor0 cursor0
52 changes: 52 additions & 0 deletions test/spec/unified-test-format/valid-fail/entity-findCursor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"description": "entity-findCursor",
"schemaVersion": "1.3",
"createEntities": [
{
"client": {
"id": "client0"
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0Name"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "coll0"
}
}
],
"initialData": [
{
"databaseName": "database0Name",
"collectionName": "coll0",
"documents": []
}
],
"tests": [
{
"description": "iterateUntilDocumentOrError fails if it references a nonexistent entity",
"operations": [
{
"name": "iterateUntilDocumentOrError",
"object": "cursor0"
}
]
},
{
"description": "close fails if it references a nonexistent entity",
"operations": [
{
"name": "close",
"object": "cursor0"
}
]
}
]
}
31 changes: 31 additions & 0 deletions test/spec/unified-test-format/valid-fail/entity-findCursor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
description: entity-findCursor

schemaVersion: '1.3'

createEntities:
- client:
id: &client0 client0
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name database0Name
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0

initialData:
- databaseName: *database0Name
collectionName: *collection0Name
documents: []

tests:
- description: iterateUntilDocumentOrError fails if it references a nonexistent entity
operations:
- name: iterateUntilDocumentOrError
object: cursor0

- description: close fails if it references a nonexistent entity
operations:
- name: close
object: cursor0
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"description": "ignoreResultAndError-malformed",
"schemaVersion": "1.3",
"createEntities": [
{
"client": {
"id": "client0",
"useMultipleMongoses": true
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0Name"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "coll0"
}
}
],
"initialData": [
{
"collectionName": "coll0",
"databaseName": "database0Name",
"documents": []
}
],
"tests": [
{
"description": "malformed operation fails if ignoreResultAndError is true",
"operations": [
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"foo": "bar"
},
"ignoreResultAndError": true
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This test is split out into a separate file to accommodate drivers that validate operation structure while decoding
# from JSON/YML. Such drivers fail to decode any files containing invalid operations. Combining this test in a file
# with other ignoreResultAndError valid-fail tests, which test failures that occur during test execution, would prevent
# such drivers from decoding the file and running any of the tests.
description: ignoreResultAndError-malformed

schemaVersion: '1.3'

createEntities:
- client:
id: &client0 client0
useMultipleMongoses: true
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name database0Name
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0

initialData:
- collectionName: *collection0Name
databaseName: *database0Name
documents: []

tests:
- description: malformed operation fails if ignoreResultAndError is true
operations:
- name: insertOne
object: *collection0
arguments:
foo: bar
ignoreResultAndError: true
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@
"ignoreResultAndError": false
}
]
},
{
"description": "malformed operation fails if ignoreResultAndError is true",
"operations": [
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"foo": "bar"
},
"ignoreResultAndError": true
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,3 @@ tests:
# Insert the same document to force a DuplicateKey error.
document: *insertDocument
ignoreResultAndError: false

- description: malformed operation fails if ignoreResultAndError is true
operations:
- name: insertOne
object: *collection0
arguments:
foo: bar
ignoreResultAndError: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"description": "operation-unsupported",
"schemaVersion": "1.0",
"createEntities": [
{
"client": {
"id": "client0"
}
}
],
"tests": [
{
"description": "Unsupported operation",
"operations": [
{
"name": "unsupportedOperation",
"object": "client0"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
description: "operation-unsupported"

schemaVersion: "1.0"

createEntities:
- client:
id: &client0 client0

tests:
- description: "Unsupported operation"
operations:
- name: unsupportedOperation
object: *client0
Loading