Skip to content

Commit 19abca4

Browse files
committed
CSHARP-4177: Sync'd collection-management spec tests.
1 parent b50dd70 commit 19abca4

File tree

3 files changed

+175
-20
lines changed

3 files changed

+175
-20
lines changed

tests/MongoDB.Driver.Tests/Specifications/collection-management/tests/README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ Collection Management Tests
33
===========================
44

55
This directory contains tests for collection management. They are implemented
6-
in the `Unified Test Format <../../unified-test-format/unified-test-format.rst>`__
7-
and require schema version 1.0.
6+
in the `Unified Test Format <../../unified-test-format/unified-test-format.rst>`__.

tests/MongoDB.Driver.Tests/Specifications/collection-management/tests/clustered-indexes.json

Lines changed: 121 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
{
22
"description": "clustered-indexes",
3-
"schemaVersion": "1.0",
3+
"schemaVersion": "1.4",
44
"runOnRequirements": [
55
{
6-
"minServerVersion": "5.3"
6+
"minServerVersion": "5.3",
7+
"serverless": "forbid"
78
}
89
],
910
"createEntities": [
1011
{
1112
"client": {
12-
"id": "client0"
13+
"id": "client0",
14+
"observeEvents": [
15+
"commandStartedEvent"
16+
]
1317
}
1418
},
1519
{
1620
"database": {
1721
"id": "database0",
1822
"client": "client0",
19-
"databaseName": "ts-tests"
23+
"databaseName": "ci-tests"
2024
}
2125
},
2226
{
@@ -30,7 +34,7 @@
3034
"initialData": [
3135
{
3236
"collectionName": "test",
33-
"databaseName": "ts-tests",
37+
"databaseName": "ci-tests",
3438
"documents": []
3539
}
3640
],
@@ -63,10 +67,40 @@
6367
"name": "assertCollectionExists",
6468
"object": "testRunner",
6569
"arguments": {
66-
"databaseName": "ts-tests",
70+
"databaseName": "ci-tests",
6771
"collectionName": "test"
6872
}
6973
}
74+
],
75+
"expectEvents": [
76+
{
77+
"client": "client0",
78+
"events": [
79+
{
80+
"commandStartedEvent": {
81+
"command": {
82+
"drop": "test"
83+
},
84+
"databaseName": "ci-tests"
85+
}
86+
},
87+
{
88+
"commandStartedEvent": {
89+
"command": {
90+
"create": "test",
91+
"clusteredIndex": {
92+
"key": {
93+
"_id": 1
94+
},
95+
"unique": true,
96+
"name": "test index"
97+
}
98+
},
99+
"databaseName": "ci-tests"
100+
}
101+
}
102+
]
103+
}
70104
]
71105
},
72106
{
@@ -124,6 +158,49 @@
124158
}
125159
]
126160
}
161+
],
162+
"expectEvents": [
163+
{
164+
"client": "client0",
165+
"events": [
166+
{
167+
"commandStartedEvent": {
168+
"command": {
169+
"drop": "test"
170+
},
171+
"databaseName": "ci-tests"
172+
}
173+
},
174+
{
175+
"commandStartedEvent": {
176+
"command": {
177+
"create": "test",
178+
"clusteredIndex": {
179+
"key": {
180+
"_id": 1
181+
},
182+
"unique": true,
183+
"name": "test index"
184+
}
185+
},
186+
"databaseName": "ci-tests"
187+
}
188+
},
189+
{
190+
"commandStartedEvent": {
191+
"command": {
192+
"listCollections": 1,
193+
"filter": {
194+
"name": {
195+
"$eq": "test"
196+
}
197+
}
198+
},
199+
"databaseName": "ci-tests"
200+
}
201+
}
202+
]
203+
}
127204
]
128205
},
129206
{
@@ -170,6 +247,44 @@
170247
}
171248
]
172249
}
250+
],
251+
"expectEvents": [
252+
{
253+
"client": "client0",
254+
"events": [
255+
{
256+
"commandStartedEvent": {
257+
"command": {
258+
"drop": "test"
259+
},
260+
"databaseName": "ci-tests"
261+
}
262+
},
263+
{
264+
"commandStartedEvent": {
265+
"command": {
266+
"create": "test",
267+
"clusteredIndex": {
268+
"key": {
269+
"_id": 1
270+
},
271+
"unique": true,
272+
"name": "test index"
273+
}
274+
},
275+
"databaseName": "ci-tests"
276+
}
277+
},
278+
{
279+
"commandStartedEvent": {
280+
"command": {
281+
"listIndexes": "test"
282+
},
283+
"databaseName": "ci-tests"
284+
}
285+
}
286+
]
287+
}
173288
]
174289
}
175290
]

tests/MongoDB.Driver.Tests/Specifications/collection-management/tests/clustered-indexes.yml

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
description: "clustered-indexes"
22

3-
schemaVersion: "1.0"
3+
schemaVersion: "1.4"
44

55
runOnRequirements:
66
- minServerVersion: "5.3"
7+
serverless: forbid
78

89
createEntities:
910
- client:
1011
id: &client0 client0
12+
observeEvents: [ commandStartedEvent ]
1113
- database:
1214
id: &database0 database0
1315
client: *client0
14-
databaseName: &database0Name ts-tests
16+
databaseName: &database0Name ci-tests
1517
- collection:
1618
id: &collection0 collection0
1719
database: *database0
@@ -33,7 +35,7 @@ tests:
3335
object: *database0
3436
arguments:
3537
collection: *collection0Name
36-
clusteredIndex:
38+
clusteredIndex: &clusteredIndex
3739
key: { _id: 1 }
3840
unique: true
3941
name: &index0Name "test index"
@@ -42,6 +44,18 @@ tests:
4244
arguments:
4345
databaseName: *database0Name
4446
collectionName: *collection0Name
47+
expectEvents:
48+
- client: *client0
49+
events:
50+
- commandStartedEvent:
51+
command:
52+
drop: *collection0Name
53+
databaseName: *database0Name
54+
- commandStartedEvent:
55+
command:
56+
create: *collection0Name
57+
clusteredIndex: *clusteredIndex
58+
databaseName: *database0Name
4559

4660
- description: "listCollections includes clusteredIndex"
4761
operations:
@@ -53,14 +67,11 @@ tests:
5367
object: *database0
5468
arguments:
5569
collection: *collection0Name
56-
clusteredIndex:
57-
key: { _id: 1 }
58-
unique: true
59-
name: &index0Name "test index"
70+
clusteredIndex: *clusteredIndex
6071
- name: listCollections
6172
object: *database0
6273
arguments:
63-
filter: { name: { $eq: *collection0Name } }
74+
filter: &filter { name: { $eq: *collection0Name } }
6475
expectResult:
6576
- name: *collection0Name
6677
options:
@@ -69,6 +80,23 @@ tests:
6980
unique: true
7081
name: *index0Name
7182
v: { $$type: [ int, long ] }
83+
expectEvents:
84+
- client: *client0
85+
events:
86+
- commandStartedEvent:
87+
command:
88+
drop: *collection0Name
89+
databaseName: *database0Name
90+
- commandStartedEvent:
91+
command:
92+
create: *collection0Name
93+
clusteredIndex: *clusteredIndex
94+
databaseName: *database0Name
95+
- commandStartedEvent:
96+
command:
97+
listCollections: 1
98+
filter: *filter
99+
databaseName: *database0Name
72100

73101
- description: "listIndexes returns the index"
74102
operations:
@@ -80,10 +108,7 @@ tests:
80108
object: *database0
81109
arguments:
82110
collection: *collection0Name
83-
clusteredIndex:
84-
key: { _id: 1 }
85-
unique: true
86-
name: *index0Name
111+
clusteredIndex: *clusteredIndex
87112
- name: listIndexes
88113
object: *collection0
89114
expectResult:
@@ -92,3 +117,19 @@ tests:
92117
clustered: true
93118
unique: true
94119
v: { $$type: [ int, long ] }
120+
expectEvents:
121+
- client: *client0
122+
events:
123+
- commandStartedEvent:
124+
command:
125+
drop: *collection0Name
126+
databaseName: *database0Name
127+
- commandStartedEvent:
128+
command:
129+
create: *collection0Name
130+
clusteredIndex: *clusteredIndex
131+
databaseName: *database0Name
132+
- commandStartedEvent:
133+
command:
134+
listIndexes: *collection0Name
135+
databaseName: *database0Name

0 commit comments

Comments
 (0)