Debian Codegraph @

testdata/command-monitoring/updateOne.yml

raw symbols SCIP
1 description: "updateOne"
2
3 schemaVersion: "1.0"
4
5 createEntities:
6 - client:
7 id: &client client
8 observeEvents:
9 - commandStartedEvent
10 - commandSucceededEvent
11 - commandFailedEvent
12 - database:
13 id: &database database
14 client: *client
15 databaseName: &databaseName command-monitoring-tests
16 - collection:
17 id: &collection collection
18 database: *database
19 collectionName: &collectionName test
20
21 initialData:
22 - collectionName: *collectionName
23 databaseName: *databaseName
24 documents:
25 - { _id: 1, x: 11 }
26 - { _id: 2, x: 22 }
27 - { _id: 3, x: 33 }
28
29 tests:
30 - description: "A successful updateOne"
31 operations:
32 - name: updateOne
33 object: *collection
34 arguments:
35 filter: { _id: { $gt: 1 } }
36 update: { $inc: { x: 1 } }
37 expectEvents:
38 - client: *client
39 events:
40 - commandStartedEvent:
41 command:
42 update: *collectionName
43 updates:
44 - q: { _id: { $gt: 1 } }
45 u: { $inc: { x: 1 } }
46 upsert: { $$unsetOrMatches: false }
47 multi: { $$unsetOrMatches: false }
48 ordered: true
49 commandName: update
50 databaseName: *databaseName
51 - commandSucceededEvent:
52 reply: { ok: 1, n: 1 }
53 commandName: update
54
55 - description: "A successful updateOne with upsert where the upserted id is not an ObjectId"
56 operations:
57 - name: updateOne
58 object: *collection
59 arguments:
60 filter: { _id: 4 }
61 update: { $inc: { x: 1 } }
62 upsert: true
63 expectEvents:
64 - client: *client
65 events:
66 - commandStartedEvent:
67 command:
68 update: *collectionName
69 updates:
70 - q: { _id: 4 }
71 u: { $inc: { x: 1 } }
72 upsert: true
73 multi: { $$unsetOrMatches: false }
74 ordered: true
75 commandName: update
76 databaseName: *databaseName
77 - commandSucceededEvent:
78 reply:
79 ok: 1
80 n: 1
81 upserted:
82 - index: 0
83 _id: 4
84 commandName: update
85
86 - description: "A successful updateOne with write errors"
87 operations:
88 - name: updateOne
89 object: *collection
90 arguments:
91 filter: { _id: { $gt: 1 } }
92 update: { $unsupported: { x: 1 } }
93 expectError:
94 isClientError: false
95 expectEvents:
96 - client: *client
97 events:
98 - commandStartedEvent:
99 command:
100 update: *collectionName
101 updates:
102 - q: { _id: { $gt: 1 } }
103 u: { $unsupported: { x: 1 } }
104 upsert: { $$unsetOrMatches: false }
105 multi: { $$unsetOrMatches: false }
106 ordered: true
107 commandName: update
108 databaseName: *databaseName
109 - commandSucceededEvent:
110 reply:
111 ok: 1
112 n: 0
113 # The legacy version of this test included an assertion that writeErrors contained a single document
114 # with index=0, a "code" value, and a non-empty "errmsg". However, writeErrors can contain extra fields
115 # beyond these, and the unified format currently does not permit allowing extra fields in sub-documents,
116 # so those assertions are not present here.
117 writeErrors: { $$type: array }
118 commandName: update