...
1description: "findOneAndReplace-comment"
2schemaVersion: "1.0"
3
4createEntities:
5 - client:
6 id: &client0 client0
7 observeEvents: [ commandStartedEvent ]
8 - database:
9 id: &database0 database0
10 client: *client0
11 databaseName: &database0Name crud-tests
12 - collection:
13 id: &collection0 collection0
14 database: *database0
15 collectionName: &collection0Name coll0
16
17initialData: &initialData
18 - collectionName: *collection0Name
19 databaseName: *database0Name
20 documents:
21 - { _id: 1 }
22 - { _id: 2 }
23
24tests:
25 - description: "findOneAndReplace with string comment"
26 runOnRequirements:
27 - minServerVersion: "4.4"
28 operations:
29 - name: findOneAndReplace
30 object: *collection0
31 arguments:
32 filter: &filter
33 _id: 1
34 replacement: &replacement
35 x: 5
36 comment: "comment"
37 expectResult:
38 _id: 1
39 expectEvents:
40 - client: *client0
41 events:
42 - commandStartedEvent:
43 command:
44 findAndModify: *collection0Name
45 query: *filter
46 update: *replacement
47 comment: "comment"
48 outcome: &outcome
49 - collectionName: *collection0Name
50 databaseName: *database0Name
51 documents:
52 - { _id: 1, x: 5 }
53 - { _id: 2 }
54
55 - description: "findOneAndReplace with document comment"
56 runOnRequirements:
57 - minServerVersion: "4.4"
58 operations:
59 - name: findOneAndReplace
60 object: *collection0
61 arguments:
62 filter: *filter
63 replacement: *replacement
64 comment: &comment { key: "value"}
65 expectResult:
66 _id: 1
67 expectEvents:
68 - client: *client0
69 events:
70 - commandStartedEvent:
71 command:
72 findAndModify: *collection0Name
73 query: *filter
74 update: *replacement
75 comment: *comment
76 outcome: *outcome
77
78
79 - description: "findOneAndReplace with comment - pre 4.4"
80 runOnRequirements:
81 - minServerVersion: "4.2.0" # findAndModify option validation was introduced in 4.2
82 maxServerVersion: "4.2.99"
83 operations:
84 - name: findOneAndReplace
85 object: *collection0
86 arguments:
87 filter: *filter
88 replacement: *replacement
89 comment: "comment"
90 expectError:
91 isClientError: false
92 expectEvents:
93 - client: *client0
94 events:
95 - commandStartedEvent:
96 command:
97 findAndModify: *collection0Name
98 query: *filter
99 update: *replacement
100 comment: "comment"
101 outcome: *initialData
View as plain text