Skip to content

Commit

Permalink
DRIVERS-776: Add tests for aggregate with $out using let option (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyemin committed Jun 10, 2021
1 parent 9465cda commit 3a58fc6
Show file tree
Hide file tree
Showing 2 changed files with 236 additions and 0 deletions.
180 changes: 180 additions & 0 deletions source/crud/tests/unified/aggregate-let.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
"database": "database0",
"collectionName": "coll0"
}
},
{
"collection": {
"id": "collection1",
"database": "database0",
"collectionName": "coll1"
}
}
],
"initialData": [
Expand All @@ -34,6 +41,11 @@
"_id": 1
}
]
},
{
"collectionName": "coll1",
"databaseName": "crud-tests",
"documents": []
}
],
"tests": [
Expand Down Expand Up @@ -293,6 +305,174 @@
]
}
]
},
{
"description": "Aggregate to collection with let option",
"runOnRequirements": [
{
"minServerVersion": "5.0"
}
],
"operations": [
{
"name": "aggregate",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 1
}
},
{
"$out": "coll1"
}
],
"let": {
"id": 1
}
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"aggregate": "coll0",
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 1
}
},
{
"$out": "coll1"
}
],
"let": {
"id": 1
}
}
}
}
]
}
],
"outcome": [
{
"collectionName": "coll1",
"databaseName": "crud-tests",
"documents": [
{
"_id": 1
}
]
}
]
},
{
"description": "Aggregate to collection with let option unsupported (server-side error)",
"runOnRequirements": [
{
"minServerVersion": "2.6.0",
"maxServerVersion": "4.4.99"
}
],
"operations": [
{
"name": "aggregate",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 1
}
},
{
"$out": "coll1"
}
],
"let": {
"id": 1
}
},
"expectError": {
"errorContains": "unrecognized field 'let'",
"isClientError": false
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"aggregate": "coll0",
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 1
}
},
{
"$out": "coll1"
}
],
"let": {
"id": 1
}
}
}
}
]
}
]
}
]
}
56 changes: 56 additions & 0 deletions source/crud/tests/unified/aggregate-let.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ createEntities:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0
- collection:
id: &collection1 collection1
database: *database0
collectionName: &collection1Name coll1

initialData: &initialData
- collectionName: *collection0Name
databaseName: *database0Name
documents:
- { _id: 1 }
- collectionName: *collection1Name
databaseName: *database0Name
documents: [ ]

tests:
# TODO: Once SERVER-57403 is resolved, this test can be removed in favor of
Expand Down Expand Up @@ -115,3 +122,52 @@ tests:
aggregate: *collection0Name
pipeline: *pipeline1
let: *let1

- description: "Aggregate to collection with let option"
runOnRequirements:
- minServerVersion: "5.0"
operations:
- name: aggregate
object: *collection0
arguments:
pipeline: &pipeline2
- $match: { $expr: { $eq: ["$_id", "$$id"] } }
- $project: { _id: 1 }
- $out: *collection1Name
let: &let2
id: 1
expectEvents:
- client: *client0
events:
- commandStartedEvent:
command:
aggregate: *collection0Name
pipeline: *pipeline2
let: *let2
outcome:
- collectionName: *collection1Name
databaseName: *database0Name
documents:
- { _id: 1 }

- description: "Aggregate to collection with let option unsupported (server-side error)"
runOnRequirements:
- minServerVersion: "2.6.0"
maxServerVersion: "4.4.99"
operations:
- name: aggregate
object: *collection0
arguments:
pipeline: *pipeline2
let: *let2
expectError:
errorContains: "unrecognized field 'let'"
isClientError: false
expectEvents:
- client: *client0
events:
- commandStartedEvent:
command:
aggregate: *collection0Name
pipeline: *pipeline2
let: *let2

0 comments on commit 3a58fc6

Please sign in to comment.