Skip to content

Commit 819fec0

Browse files
committed
Example insertOne test
1 parent a8762bf commit 819fec0

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"schemaVersion": "1.0",
3+
"runOn": [
4+
{
5+
"minServerVersion": "2.6"
6+
}
7+
],
8+
"createEntites": [
9+
{
10+
"client": {
11+
"id": "client0",
12+
"observeEvents": [
13+
"commandStartedEvent"
14+
]
15+
}
16+
},
17+
{
18+
"database": {
19+
"id": "database0",
20+
"client": "client0",
21+
"databaseName": "test"
22+
}
23+
},
24+
{
25+
"collection": {
26+
"id": "collection0",
27+
"database": "database0",
28+
"collectionName": "coll"
29+
}
30+
}
31+
],
32+
"initialData": [
33+
{
34+
"collectionName": "coll",
35+
"databaseName": "test",
36+
"documents": [
37+
{
38+
"_id": 1
39+
}
40+
]
41+
}
42+
],
43+
"tests": [
44+
{
45+
"description": "insertOne",
46+
"operations": [
47+
{
48+
"object": "collection0",
49+
"name": "insertOne",
50+
"arguments": {
51+
"document": {
52+
"_id": 2
53+
}
54+
},
55+
"expectedResult": {
56+
"insertedId": {
57+
"$$unsetOrMatches": 2
58+
}
59+
}
60+
}
61+
],
62+
"expectedEvents": [
63+
{
64+
"client": "client0",
65+
"events": [
66+
{
67+
"commandStartedEvent": {
68+
"commandName": "insert",
69+
"databaseName": "test",
70+
"command": {
71+
"insert": "coll",
72+
"documents": [
73+
{
74+
"_id": 2
75+
}
76+
]
77+
}
78+
}
79+
}
80+
]
81+
}
82+
],
83+
"outcome": [
84+
{
85+
"collectionName": "coll",
86+
"databaseName": "test",
87+
"documents": [
88+
{
89+
"_id": 1
90+
},
91+
{
92+
"_id": 2
93+
}
94+
]
95+
}
96+
]
97+
}
98+
]
99+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
schemaVersion: "1.0"
2+
3+
runOn:
4+
- minServerVersion: "2.6"
5+
6+
createEntites:
7+
- client:
8+
id: &client0 client0
9+
observeEvents:
10+
- commandStartedEvent
11+
- database:
12+
id: &database0 database0
13+
client: *client0
14+
databaseName: &database0Name test
15+
- collection:
16+
id: &collection0 collection0
17+
database: *database0
18+
collectionName: &collection0Name coll
19+
20+
initialData:
21+
- collectionName: *collection0Name
22+
databaseName: *database0Name
23+
documents:
24+
- { _id: 1 }
25+
26+
tests:
27+
- description: "insertOne"
28+
operations:
29+
-
30+
object: *collection0
31+
name: insertOne
32+
arguments:
33+
document: { _id: 2 }
34+
expectedResult:
35+
insertedId: { $$unsetOrMatches: 2 }
36+
expectedEvents:
37+
- client: *client0
38+
events:
39+
- commandStartedEvent:
40+
commandName: insert
41+
databaseName: *database0Name
42+
command:
43+
insert: *collection0Name
44+
documents:
45+
- { _id: 2 }
46+
outcome:
47+
- collectionName: *collection0Name
48+
databaseName: *database0Name
49+
documents:
50+
- { _id: 1 }
51+
- { _id: 2 }

0 commit comments

Comments
 (0)