Skip to content

Commit 7d9a50c

Browse files
committed
DRIVERS-2573: Common tests for $$matchAsDocument and $$matchAsRoot
1 parent e26b8cd commit 7d9a50c

File tree

8 files changed

+745
-0
lines changed

8 files changed

+745
-0
lines changed

source/unified-test-format/tests/valid-fail/operator-matchAsDocument.json

Lines changed: 147 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
description: operator-matchAsDocument
2+
3+
schemaVersion: "1.13"
4+
5+
createEntities:
6+
- client:
7+
id: &client0 client0
8+
- database:
9+
id: &database0 database0
10+
client: *client0
11+
databaseName: &database0Name test
12+
- collection:
13+
id: &collection0 collection0
14+
database: *database0
15+
collectionName: &collection0Name coll0
16+
17+
initialData:
18+
- collectionName: *collection0Name
19+
databaseName: *database0Name
20+
documents:
21+
- { _id: 1, json: '{ "x": 1, "y": 2 }' }
22+
- { _id: 2, json: '{ "x" }' }
23+
24+
tests:
25+
- description: matchAsDocument with non-matching filter
26+
operations:
27+
- name: find
28+
object: *collection0
29+
arguments:
30+
filter: { _id : 1 }
31+
limit: 1
32+
expectResult:
33+
- { _id: 1, json: { $$matchAsDocument: { x: 1, y: "two" } } }
34+
-
35+
description: matchAsDocument evaluates special operators
36+
operations:
37+
- name: find
38+
object: *collection0
39+
arguments:
40+
filter: { _id : 1 }
41+
limit: 1
42+
expectResult:
43+
- { _id: 1, json: { $$matchAsDocument: { x: 1, y: { $$exists: false } } } }
44+
-
45+
description: matchAsDocument does not permit extra fields
46+
operations:
47+
- name: find
48+
object: *collection0
49+
arguments:
50+
filter: { _id : 1 }
51+
limit: 1
52+
expectResult:
53+
- { _id: 1, json: { $$matchAsDocument: { x: 1 } } }
54+
-
55+
description: matchAsDocument fails to decode Extended JSON
56+
operations:
57+
- name: find
58+
object: *collection0
59+
arguments:
60+
filter: { _id : 2 }
61+
limit: 1
62+
expectResult:
63+
- { _id: 2, json: { $$matchAsDocument: { x: 1 } } }

source/unified-test-format/tests/valid-fail/operator-matchAsRoot.json

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
description: operator-matchAsRoot
2+
3+
schemaVersion: "1.13"
4+
5+
createEntities:
6+
- client:
7+
id: &client0 client0
8+
- database:
9+
id: &database0 database0
10+
client: *client0
11+
databaseName: &database0Name test
12+
- collection:
13+
id: &collection0 collection0
14+
database: *database0
15+
collectionName: &collection0Name coll0
16+
17+
initialData:
18+
- collectionName: *collection0Name
19+
databaseName: *database0Name
20+
documents:
21+
- { _id: 1, x: { y: 2, z: 3 } }
22+
- { _id: 2, x: '{ "x": 1, "y": 2.0 }' }
23+
24+
tests:
25+
-
26+
description: matchAsRoot with nested document
27+
operations:
28+
- name: find
29+
object: *collection0
30+
arguments:
31+
filter: { _id : 1 }
32+
limit: 1
33+
expectResult:
34+
- { _id: 1, x: { $$matchAsRoot: { y: 3 } } }
35+
-
36+
description: matchAsRoot with matchAsDocument
37+
operations:
38+
- name: find
39+
object: *collection0
40+
arguments:
41+
filter: { _id : 1 }
42+
limit: 1
43+
expectResult:
44+
- { _id: 2, x: { $$matchAsDocument: { $$matchAsRoot: { x: 1 } } } }

0 commit comments

Comments
 (0)