Skip to content

Commit

Permalink
update spec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Jan 24, 2025
1 parent 50cf0c2 commit 5051f3b
Show file tree
Hide file tree
Showing 4 changed files with 484 additions and 0 deletions.
163 changes: 163 additions & 0 deletions testdata/crud/unified/client-bulkWrite-replaceOne-sort.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{
"description": "client bulkWrite updateOne-sort",
"schemaVersion": "1.4",
"runOnRequirements": [
{
"minServerVersion": "8.0",
"serverless": "forbid"
}
],
"createEntities": [
{
"client": {
"id": "client0",
"observeEvents": [
"commandStartedEvent",
"commandSucceededEvent"
]
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "crud-tests"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "coll0"
}
}
],
"initialData": [
{
"collectionName": "coll0",
"databaseName": "crud-tests",
"documents": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
],
"_yamlAnchors": {
"namespace": "crud-tests.coll0"
},
"tests": [
{
"description": "client bulkWrite replaceOne with sort option",
"operations": [
{
"object": "client0",
"name": "clientBulkWrite",
"arguments": {
"models": [
{
"replaceOne": {
"namespace": "crud-tests.coll0",
"filter": {
"_id": {
"$gt": 1
}
},
"sort": {
"_id": -1
},
"replacement": {
"x": 1
}
}
}
]
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"commandName": "bulkWrite",
"databaseName": "admin",
"command": {
"bulkWrite": 1,
"ops": [
{
"update": 0,
"filter": {
"_id": {
"$gt": 1
}
},
"updateMods": {
"x": 1
},
"sort": {
"_id": -1
},
"multi": {
"$$unsetOrMatches": false
},
"upsert": {
"$$unsetOrMatches": false
}
}
],
"nsInfo": [
{
"ns": "crud-tests.coll0"
}
]
}
}
},
{
"commandSucceededEvent": {
"reply": {
"ok": 1,
"nErrors": 0,
"nMatched": 1,
"nModified": 1
},
"commandName": "bulkWrite"
}
}
]
}
],
"outcome": [
{
"collectionName": "coll0",
"databaseName": "crud-tests",
"documents": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 1
}
]
}
]
}
]
}
77 changes: 77 additions & 0 deletions testdata/crud/unified/client-bulkWrite-replaceOne-sort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
description: client bulkWrite updateOne-sort

schemaVersion: "1.4"

runOnRequirements:
- minServerVersion: "8.0"
serverless: forbid # Serverless does not support bulkWrite: CLOUDP-256344.

createEntities:
- client:
id: &client0 client0
observeEvents:
- commandStartedEvent
- commandSucceededEvent
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name crud-tests
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0

initialData:
- collectionName: *collection0Name
databaseName: *database0Name
documents:
- { _id: 1, x: 11 }
- { _id: 2, x: 22 }
- { _id: 3, x: 33 }

_yamlAnchors:
namespace: &namespace "crud-tests.coll0"

tests:
- description: client bulkWrite replaceOne with sort option
operations:
- object: *client0
name: clientBulkWrite
arguments:
models:
- replaceOne:
namespace: *namespace
filter: { _id: { $gt: 1 } }
sort: { _id: -1 }
replacement: { x: 1 }
expectEvents:
- client: *client0
events:
- commandStartedEvent:
commandName: bulkWrite
databaseName: admin
command:
bulkWrite: 1
ops:
- update: 0
filter: { _id: { $gt: 1 } }
updateMods: { x: 1 }
sort: { _id: -1 }
multi: { $$unsetOrMatches: false }
upsert: { $$unsetOrMatches: false }
nsInfo:
- ns: *namespace
- commandSucceededEvent:
reply:
ok: 1
nErrors: 0
nMatched: 1
nModified: 1
commandName: bulkWrite
outcome:
- collectionName: *collection0Name
databaseName: *database0Name
documents:
- { _id: 1, x: 11 }
- { _id: 2, x: 22 }
- { _id: 3, x: 1 }
Loading

0 comments on commit 5051f3b

Please sign in to comment.