Skip to content
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
36 changes: 20 additions & 16 deletions source/crud/tests/unified/insertMany-dots_and_dollars.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@
]
},
"expectResult": {
"insertedCount": 1,
"insertedIds": {
"$$unsetOrMatches": {
"0": 1
"$$unsetOrMatches": {
"insertedIds": {
"$$unsetOrMatches": {
"0": 1
}
}
}
}
Expand Down Expand Up @@ -162,10 +163,11 @@
]
},
"expectResult": {
"insertedCount": 1,
"insertedIds": {
"$$unsetOrMatches": {
"0": 1
"$$unsetOrMatches": {
"insertedIds": {
"$$unsetOrMatches": {
"0": 1
}
}
}
}
Expand Down Expand Up @@ -221,10 +223,11 @@
]
},
"expectResult": {
"insertedCount": 1,
"insertedIds": {
"$$unsetOrMatches": {
"0": 1
"$$unsetOrMatches": {
"insertedIds": {
"$$unsetOrMatches": {
"0": 1
}
}
}
}
Expand Down Expand Up @@ -284,10 +287,11 @@
]
},
"expectResult": {
"insertedCount": 1,
"insertedIds": {
"$$unsetOrMatches": {
"0": 1
"$$unsetOrMatches": {
"insertedIds": {
"$$unsetOrMatches": {
"0": 1
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/crud/tests/unified/insertMany-dots_and_dollars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ tests:
documents:
- &dollarPrefixedKey { _id: 1, $a: 1 }
expectResult: &insertResult
insertedCount: 1
insertedIds: { $$unsetOrMatches: { 0: 1 } }
# InsertManyResult is optional because all of its fields are optional
$$unsetOrMatches: { insertedIds: { $$unsetOrMatches: { 0: 1 } } }
expectEvents: &expectEventsDollarPrefixedKey
- client: *client0
events:
Expand Down
44 changes: 29 additions & 15 deletions source/crud/tests/unified/insertOne-dots_and_dollars.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
}
},
"expectResult": {
"insertedId": {
"$$unsetOrMatches": 1
"$$unsetOrMatches": {
"insertedId": {
"$$unsetOrMatches": 1
}
}
}
}
Expand Down Expand Up @@ -165,8 +167,10 @@
}
},
"expectResult": {
"insertedId": {
"$$unsetOrMatches": 1
"$$unsetOrMatches": {
"insertedId": {
"$$unsetOrMatches": 1
}
}
}
}
Expand Down Expand Up @@ -219,8 +223,10 @@
}
},
"expectResult": {
"insertedId": {
"$$unsetOrMatches": 1
"$$unsetOrMatches": {
"insertedId": {
"$$unsetOrMatches": 1
}
}
}
}
Expand Down Expand Up @@ -277,8 +283,10 @@
}
},
"expectResult": {
"insertedId": {
"$$unsetOrMatches": 1
"$$unsetOrMatches": {
"insertedId": {
"$$unsetOrMatches": 1
}
}
}
}
Expand Down Expand Up @@ -386,9 +394,11 @@
}
},
"expectResult": {
"insertedId": {
"$$unsetOrMatches": {
"a.b": 1
"$$unsetOrMatches": {
"insertedId": {
"$$unsetOrMatches": {
"a.b": 1
}
}
}
}
Expand Down Expand Up @@ -496,8 +506,10 @@
}
},
"expectResult": {
"insertedId": {
"$$unsetOrMatches": 1
"$$unsetOrMatches": {
"insertedId": {
"$$unsetOrMatches": 1
}
}
}
}
Expand Down Expand Up @@ -558,8 +570,10 @@
}
},
"expectResult": {
"acknowledged": {
"$$unsetOrMatches": false
"$$unsetOrMatches": {
"acknowledged": {
"$$unsetOrMatches": false
}
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions source/crud/tests/unified/insertOne-dots_and_dollars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ tests:
arguments:
document: &dollarPrefixedKey { _id: 1, $a: 1 }
expectResult: &insertResult
insertedId: { $$unsetOrMatches: 1 }
# InsertOneResult is optional because all of its fields are optional
$$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } }
expectEvents: &expectEventsDollarPrefixedKey
- client: *client0
events:
Expand Down Expand Up @@ -155,7 +156,8 @@ tests:
arguments:
document: &dottedKeyInId { _id: { a.b: 1 } }
expectResult:
insertedId: { $$unsetOrMatches: { a.b: 1 } }
# InsertOneResult is optional because all of its fields are optional
$$unsetOrMatches: { insertedId: { $$unsetOrMatches: { a.b: 1 } } }
expectEvents: &expectEventsDottedKeyInId
- client: *client0
events:
Expand Down Expand Up @@ -222,7 +224,8 @@ tests:
arguments:
document: *dollarPrefixedKeyInId
expectResult:
acknowledged: { $$unsetOrMatches: false }
# InsertOneResult is optional because all of its fields are optional
$$unsetOrMatches: { acknowledged: { $$unsetOrMatches: false } }
expectEvents:
- client: *client0
events:
Expand Down
14 changes: 8 additions & 6 deletions source/unified-test-format/tests/valid-pass/poc-crud.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,14 @@
},
"expectError": {
"expectResult": {
"deletedCount": 0,
"insertedCount": 2,
"matchedCount": 0,
"modifiedCount": 0,
"upsertedCount": 0,
"upsertedIds": {}
"$$unsetOrMatches": {
"deletedCount": 0,
"insertedCount": 2,
"matchedCount": 0,
"modifiedCount": 0,
"upsertedCount": 0,
"upsertedIds": {}
}
}
}
}
Expand Down
23 changes: 13 additions & 10 deletions source/unified-test-format/tests/valid-pass/poc-crud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,19 @@ tests:
ordered: false
expectError:
expectResult:
deletedCount: 0
insertedCount: 2
# Since the map of insertedIds is generated before execution it
# could indicate inserts that did not actually succeed. We omit
# this field rather than expect drivers to provide an accurate
# map filtered by write errors.
matchedCount: 0
modifiedCount: 0
upsertedCount: 0
upsertedIds: { }
# insertMany throws BulkWriteException, which may optionally include
# an intermediary BulkWriteResult
$$unsetOrMatches:
deletedCount: 0
insertedCount: 2
# Since the map of insertedIds is generated before execution it
# could indicate inserts that did not actually succeed. We omit
# this field rather than expect drivers to provide an accurate
# map filtered by write errors.
matchedCount: 0
modifiedCount: 0
upsertedCount: 0
upsertedIds: { }
outcome:
- collectionName: *collection1Name
databaseName: *database0Name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@
},
"expectResult": {
"$$unsetOrMatches": {
"insertedCount": {
"$$unsetOrMatches": 2
},
"insertedIds": {
"$$unsetOrMatches": {
"0": 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ tests:
- { _id: 4, x: 44 }
ordered: true
expectResult:
$$unsetOrMatches:
insertedCount: { $$unsetOrMatches: 2 }
insertedIds: { $$unsetOrMatches: { 0: 3, 1: 4 } }
# InsertManyResult is optional because all of its fields are optional
$$unsetOrMatches: { insertedIds: { $$unsetOrMatches: { 0: 3, 1: 4 } } }
outcome:
- collectionName: *collectionName
databaseName: *databaseName
Expand Down
11 changes: 8 additions & 3 deletions source/unified-test-format/unified-test-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Unified Test Format
===================

:Spec Title: Unified Test Format
:Spec Version: 1.5.1
:Spec Version: 1.5.2
:Author: Jeremy Mikola
:Advisors: Prashant Mital, Isabel Atkinson, Thomas Reggi
:Status: Accepted
:Type: Standards
:Minimum Server Version: N/A
:Last Modified: 2021-06-28
:Last Modified: 2021-07-01

.. contents::

Expand Down Expand Up @@ -972,7 +972,9 @@ The structure of this object is as follows:
`operation.expectResult <operation_expectResult_>`_ and is only used in cases
where the error includes a result (e.g. `bulkWrite`_). If specified, the test
runner MUST assert that the error includes a result and that it matches this
value.
value. If the result is optional (e.g. BulkWriteResult reported through the
``writeResult`` property of a BulkWriteException), this assertion SHOULD
utilize the `$$unsetOrMatches`_ operator.


expectedEventsForClient
Expand Down Expand Up @@ -3240,6 +3242,9 @@ spec changes developed in parallel or during the same release cycle.
Change Log
==========

:2021-07-01: Note that ``expectError.expectResult`` should use
``$$unsetOrMatches`` when the result is optional.

:2021-06-09: Added an ``observeSensitiveCommands`` property to the ``client``
entity type.

Expand Down