-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
350 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
{ | ||
"description": "create-null-ids", | ||
"schemaVersion": "1.0", | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "client", | ||
"observeEvents": [ | ||
"commandStartedEvent" | ||
] | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database", | ||
"client": "client", | ||
"databaseName": "crud_id" | ||
} | ||
}, | ||
{ | ||
"collection": { | ||
"id": "collection", | ||
"database": "database", | ||
"collectionName": "type_tests" | ||
} | ||
} | ||
], | ||
"initialData": [ | ||
{ | ||
"collectionName": "type_tests", | ||
"databaseName": "crud_id", | ||
"documents": [] | ||
} | ||
], | ||
"tests": [ | ||
{ | ||
"description": "inserting _id with type null via insertOne", | ||
"operations": [ | ||
{ | ||
"name": "insertOne", | ||
"object": "collection", | ||
"arguments": { | ||
"document": { | ||
"_id": null | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "countDocuments", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": { | ||
"_id": { | ||
"$type": "null" | ||
} | ||
} | ||
}, | ||
"expectResult": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "inserting _id with type null via insertMany", | ||
"operations": [ | ||
{ | ||
"name": "insertMany", | ||
"object": "collection", | ||
"arguments": { | ||
"documents": [ | ||
{ | ||
"_id": null | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"name": "countDocuments", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": { | ||
"_id": { | ||
"$type": "null" | ||
} | ||
} | ||
}, | ||
"expectResult": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "inserting _id with type null via updateOne", | ||
"operations": [ | ||
{ | ||
"name": "updateOne", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": { | ||
"_id": null | ||
}, | ||
"update": { | ||
"$unset": { | ||
"a": "" | ||
} | ||
}, | ||
"upsert": true | ||
} | ||
}, | ||
{ | ||
"name": "countDocuments", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": { | ||
"_id": { | ||
"$type": "null" | ||
} | ||
} | ||
}, | ||
"expectResult": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "inserting _id with type null via updateMany", | ||
"operations": [ | ||
{ | ||
"name": "updateMany", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": { | ||
"_id": null | ||
}, | ||
"update": { | ||
"$unset": { | ||
"a": "" | ||
} | ||
}, | ||
"upsert": true | ||
} | ||
}, | ||
{ | ||
"name": "countDocuments", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": { | ||
"_id": { | ||
"$type": "null" | ||
} | ||
} | ||
}, | ||
"expectResult": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "inserting _id with type null via replaceOne", | ||
"operations": [ | ||
{ | ||
"name": "replaceOne", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": {}, | ||
"replacement": { | ||
"_id": null | ||
}, | ||
"upsert": true | ||
} | ||
}, | ||
{ | ||
"name": "countDocuments", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": { | ||
"_id": { | ||
"$type": "null" | ||
} | ||
} | ||
}, | ||
"expectResult": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "inserting _id with type null via bulkWrite", | ||
"operations": [ | ||
{ | ||
"name": "bulkWrite", | ||
"object": "collection", | ||
"arguments": { | ||
"requests": [ | ||
{ | ||
"insertOne": { | ||
"document": { | ||
"_id": null | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"name": "countDocuments", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": { | ||
"_id": { | ||
"$type": "null" | ||
} | ||
} | ||
}, | ||
"expectResult": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "inserting _id with type null via clientBulkWrite", | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "8.0" | ||
} | ||
], | ||
"operations": [ | ||
{ | ||
"name": "clientBulkWrite", | ||
"object": "client", | ||
"arguments": { | ||
"models": [ | ||
{ | ||
"insertOne": { | ||
"namespace": "crud_id.type_tests", | ||
"document": { | ||
"_id": null | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"name": "countDocuments", | ||
"object": "collection", | ||
"arguments": { | ||
"filter": { | ||
"_id": { | ||
"$type": "null" | ||
} | ||
} | ||
}, | ||
"expectResult": 1 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
description: create-null-ids | ||
schemaVersion: '1.0' | ||
|
||
createEntities: | ||
- client: | ||
id: client | ||
observeEvents: | ||
- commandStartedEvent | ||
- database: | ||
id: &database database | ||
client: client | ||
databaseName: crud_id | ||
- collection: | ||
id: &collection collection | ||
database: *database | ||
collectionName: type_tests | ||
|
||
initialData: | ||
- collectionName: type_tests | ||
databaseName: crud_id | ||
documents: [] | ||
|
||
tests: | ||
|
||
- description: inserting _id with type null via insertOne | ||
operations: | ||
- name: insertOne | ||
object: *collection | ||
arguments: {document: &null_id {_id: null}} | ||
# We use countDocuments with a $type query to verify the insert of the correct BSON type | ||
# this is to avoid client side type conversions (potentially common: undefined -> null) | ||
- name: countDocuments | ||
object: *collection | ||
arguments: {filter: &null_id_filter {_id: {$type: 'null'}}} | ||
expectResult: 1 | ||
|
||
- description: inserting _id with type null via insertMany | ||
operations: | ||
- name: insertMany | ||
object: *collection | ||
arguments: {documents: [*null_id]} | ||
- name: countDocuments | ||
object: *collection | ||
arguments: {filter: *null_id_filter} | ||
expectResult: 1 | ||
|
||
- description: inserting _id with type null via updateOne | ||
operations: | ||
- name: updateOne | ||
object: *collection | ||
arguments: {filter: *null_id, update: {$unset: {a: ''}}, upsert: true} | ||
- name: countDocuments | ||
object: *collection | ||
arguments: {filter: *null_id_filter} | ||
expectResult: 1 | ||
|
||
- description: inserting _id with type null via updateMany | ||
operations: | ||
- name: updateMany | ||
object: *collection | ||
arguments: {filter: *null_id, update: {$unset: {a: ''}}, upsert: true} | ||
- name: countDocuments | ||
object: *collection | ||
arguments: {filter: *null_id_filter} | ||
expectResult: 1 | ||
|
||
- description: inserting _id with type null via replaceOne | ||
operations: | ||
- name: replaceOne | ||
object: *collection | ||
arguments: {filter: {}, replacement: *null_id, upsert: true} | ||
- name: countDocuments | ||
object: *collection | ||
arguments: {filter: *null_id_filter} | ||
expectResult: 1 | ||
|
||
- description: inserting _id with type null via bulkWrite | ||
operations: | ||
- name: bulkWrite | ||
object: *collection | ||
arguments: {requests: [{insertOne: {document: *null_id}}]} | ||
- name: countDocuments | ||
object: *collection | ||
arguments: {filter: *null_id_filter} | ||
expectResult: 1 | ||
|
||
- description: inserting _id with type null via clientBulkWrite | ||
runOnRequirements: | ||
- minServerVersion: '8.0' | ||
operations: | ||
- name: clientBulkWrite | ||
object: client | ||
arguments: {models: [{insertOne: {namespace: crud_id.type_tests, document: *null_id}}]} | ||
- name: countDocuments | ||
object: *collection | ||
arguments: {filter: *null_id_filter} | ||
expectResult: 1 |