Skip to content

Commit be19511

Browse files
test: add unified tests for disambiguatedPaths
1 parent f28ba0d commit be19511

File tree

2 files changed

+338
-0
lines changed

2 files changed

+338
-0
lines changed
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
{
2+
"description": "disambiguatedPaths",
3+
"schemaVersion": "1.9",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"useMultipleMongoses": false
9+
}
10+
},
11+
{
12+
"database": {
13+
"id": "database0",
14+
"client": "client0",
15+
"databaseName": "database0"
16+
}
17+
},
18+
{
19+
"collection": {
20+
"id": "collection0",
21+
"database": "database0",
22+
"collectionName": "collection0"
23+
}
24+
}
25+
],
26+
"initialData": [
27+
{
28+
"collectionName": "collection0",
29+
"databaseName": "database0",
30+
"documents": []
31+
}
32+
],
33+
"tests": [
34+
{
35+
"description": "disambiguatedPaths is not present when showExpandedEvents is false/unset",
36+
"operations": [
37+
{
38+
"name": "insertOne",
39+
"object": "collection0",
40+
"arguments": {
41+
"document": {
42+
"_id": 1,
43+
"a": {
44+
"1": 1
45+
}
46+
}
47+
}
48+
},
49+
{
50+
"name": "createChangeStream",
51+
"object": "collection0",
52+
"arguments": {
53+
"pipeline": []
54+
},
55+
"saveResultAsEntity": "changeStream0"
56+
},
57+
{
58+
"name": "updateOne",
59+
"object": "collection0",
60+
"arguments": {
61+
"filter": {
62+
"_id": 1
63+
},
64+
"update": {
65+
"$set": {
66+
"a.1": 2
67+
}
68+
}
69+
}
70+
},
71+
{
72+
"name": "iterateUntilDocumentOrError",
73+
"object": "changeStream0",
74+
"expectResult": {
75+
"operationType": "update",
76+
"ns": {
77+
"db": "database0",
78+
"coll": "collection0"
79+
},
80+
"updateDescription": {
81+
"updatedFields": {
82+
"$$exists": true
83+
},
84+
"removedFields": {
85+
"$$exists": true
86+
},
87+
"truncatedArrays": {
88+
"$$exists": true
89+
},
90+
"disambiguatedPaths": {
91+
"$$exists": false
92+
}
93+
}
94+
}
95+
}
96+
]
97+
},
98+
{
99+
"description": "disambiguatedPaths is present on updateDescription when an ambiguous path is present",
100+
"operations": [
101+
{
102+
"name": "insertOne",
103+
"object": "collection0",
104+
"arguments": {
105+
"document": {
106+
"_id": 1,
107+
"a": {
108+
"1": 1
109+
}
110+
}
111+
}
112+
},
113+
{
114+
"name": "createChangeStream",
115+
"object": "collection0",
116+
"arguments": {
117+
"pipeline": [],
118+
"showExpandedEvents": true
119+
},
120+
"saveResultAsEntity": "changeStream0"
121+
},
122+
{
123+
"name": "updateOne",
124+
"object": "collection0",
125+
"arguments": {
126+
"filter": {
127+
"_id": 1
128+
},
129+
"update": {
130+
"$set": {
131+
"a.1": 2
132+
}
133+
}
134+
}
135+
},
136+
{
137+
"name": "iterateUntilDocumentOrError",
138+
"object": "changeStream0",
139+
"expectResult": {
140+
"operationType": "update",
141+
"ns": {
142+
"db": "database0",
143+
"coll": "collection0"
144+
},
145+
"updateDescription": {
146+
"updatedFields": {
147+
"$$exists": true
148+
},
149+
"removedFields": {
150+
"$$exists": true
151+
},
152+
"truncatedArrays": {
153+
"$$exists": true
154+
},
155+
"disambiguatedPaths": {
156+
"a.1": [
157+
"a",
158+
"1"
159+
]
160+
}
161+
}
162+
}
163+
}
164+
]
165+
},
166+
{
167+
"description": "disambiguatedPaths returns array indices as integers",
168+
"operations": [
169+
{
170+
"name": "insertOne",
171+
"object": "collection0",
172+
"arguments": {
173+
"document": {
174+
"_id": 1,
175+
"a": [
176+
{
177+
"1": 1
178+
}
179+
]
180+
}
181+
}
182+
},
183+
{
184+
"name": "createChangeStream",
185+
"object": "collection0",
186+
"arguments": {
187+
"pipeline": [],
188+
"showExpandedEvents": true
189+
},
190+
"saveResultAsEntity": "changeStream0"
191+
},
192+
{
193+
"name": "updateOne",
194+
"object": "collection0",
195+
"arguments": {
196+
"filter": {
197+
"_id": 1
198+
},
199+
"update": {
200+
"$set": {
201+
"a.0.1": 2
202+
}
203+
}
204+
}
205+
},
206+
{
207+
"name": "iterateUntilDocumentOrError",
208+
"object": "changeStream0",
209+
"expectResult": {
210+
"operationType": "update",
211+
"ns": {
212+
"db": "database0",
213+
"coll": "collection0"
214+
},
215+
"updateDescription": {
216+
"updatedFields": {
217+
"$$exists": true
218+
},
219+
"removedFields": {
220+
"$$exists": true
221+
},
222+
"truncatedArrays": {
223+
"$$exists": true
224+
},
225+
"disambiguatedPaths": {
226+
"a.0.1": [
227+
"a",
228+
{
229+
"$$type": "int"
230+
},
231+
"1"
232+
]
233+
}
234+
}
235+
}
236+
}
237+
]
238+
}
239+
]
240+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
description: "disambiguatedPaths"
2+
schemaVersion: "1.9" # todo - choose schema version
3+
createEntities:
4+
- client:
5+
id: &client0 client0
6+
useMultipleMongoses: false
7+
- database:
8+
id: &database0 database0
9+
client: *client0
10+
databaseName: *database0
11+
- collection:
12+
id: &collection0 collection0
13+
database: *database0
14+
collectionName: *collection0
15+
16+
initialData:
17+
- collectionName: *collection0
18+
databaseName: *database0
19+
documents: []
20+
21+
tests:
22+
- description: "disambiguatedPaths is not present when showExpandedEvents is false/unset"
23+
operations:
24+
- name: insertOne
25+
object: *collection0
26+
arguments:
27+
document: { _id: 1, 'a': { '1': 1 } }
28+
- name: createChangeStream
29+
object: *collection0
30+
arguments: { pipeline: [] }
31+
saveResultAsEntity: &changeStream0 changeStream0
32+
- name: updateOne
33+
object: *collection0
34+
arguments:
35+
filter: { _id: 1 }
36+
update: { $set: { 'a.1': 2 } }
37+
- name: iterateUntilDocumentOrError
38+
object: *changeStream0
39+
expectResult:
40+
operationType: "update"
41+
ns: { db: *database0, coll: *collection0 }
42+
updateDescription:
43+
updatedFields: { $$exists: true }
44+
removedFields: { $$exists: true }
45+
truncatedArrays: { $$exists: true }
46+
disambiguatedPaths: { $$exists: false }
47+
48+
- description: "disambiguatedPaths is present on updateDescription when an ambiguous path is present"
49+
operations:
50+
- name: insertOne
51+
object: *collection0
52+
arguments:
53+
document: { _id: 1, 'a': { '1': 1 } }
54+
- name: createChangeStream
55+
object: *collection0
56+
arguments: { pipeline: [], showExpandedEvents: true }
57+
saveResultAsEntity: &changeStream0 changeStream0
58+
- name: updateOne
59+
object: *collection0
60+
arguments:
61+
filter: { _id: 1 }
62+
update: { $set: { 'a.1': 2 } }
63+
- name: iterateUntilDocumentOrError
64+
object: *changeStream0
65+
expectResult:
66+
operationType: "update"
67+
ns: { db: *database0, coll: *collection0 }
68+
updateDescription:
69+
updatedFields: { $$exists: true }
70+
removedFields: { $$exists: true }
71+
truncatedArrays: { $$exists: true }
72+
disambiguatedPaths: { 'a.1': ['a', '1'] }
73+
74+
- description: "disambiguatedPaths returns array indices as integers"
75+
operations:
76+
- name: insertOne
77+
object: *collection0
78+
arguments:
79+
document: { _id: 1, 'a': [{'1': 1 }] }
80+
- name: createChangeStream
81+
object: *collection0
82+
arguments: { pipeline: [], showExpandedEvents: true }
83+
saveResultAsEntity: &changeStream0 changeStream0
84+
- name: updateOne
85+
object: *collection0
86+
arguments:
87+
filter: { _id: 1 }
88+
update: { $set: { 'a.0.1': 2 } }
89+
- name: iterateUntilDocumentOrError
90+
object: *changeStream0
91+
expectResult:
92+
operationType: "update"
93+
ns: { db: *database0, coll: *collection0 }
94+
updateDescription:
95+
updatedFields: { $$exists: true }
96+
removedFields: { $$exists: true }
97+
truncatedArrays: { $$exists: true }
98+
disambiguatedPaths: { 'a.0.1': ['a', { $$type: 'int' }, '1'] }

0 commit comments

Comments
 (0)