Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(NODE-3698): sync spec tests for crud operations with let option #3147

Merged
merged 11 commits into from
Feb 18, 2022
103 changes: 0 additions & 103 deletions test/spec/crud/unified/aggregate-let.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,109 +56,6 @@
"minServerVersion": "5.0"
}
],
"operations": [
{
"name": "aggregate",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 0,
"x": "$$x",
"y": "$$y",
"rand": "$$rand"
}
}
],
"let": {
"id": 1,
"x": "foo",
"y": {
"$literal": "bar"
},
"rand": {
"$rand": {}
}
}
},
"expectResult": [
{
"x": "foo",
"y": "bar",
"rand": {
"$$type": "double"
}
}
]
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"aggregate": "coll0",
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 0,
"x": "$$x",
"y": "$$y",
"rand": "$$rand"
}
}
],
"let": {
"id": 1,
"x": "foo",
"y": {
"$literal": "bar"
},
"rand": {
"$rand": {}
}
}
}
}
}
]
}
]
},
{
"description": "Aggregate with let option and dollar-prefixed $literal value",
"runOnRequirements": [
{
"minServerVersion": "5.0",
"topologies": [
"single",
"replicaset"
]
}
],
"operations": [
{
"name": "aggregate",
Expand Down
36 changes: 0 additions & 36 deletions test/spec/crud/unified/aggregate-let.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,9 @@ initialData: &initialData
documents: [ ]

tests:
# TODO: Once SERVER-57403 is resolved, this test can be removed in favor of
# the "dollar-prefixed $literal value" test below.
- description: "Aggregate with let option"
runOnRequirements:
- minServerVersion: "5.0"
operations:
- name: aggregate
object: *collection0
arguments:
pipeline: &pipeline0
# $match takes a query expression, so $expr is necessary to utilize
# an aggregate expression context and access "let" variables.
- $match: { $expr: { $eq: ["$_id", "$$id"] } }
- $project: { _id: 0, x: "$$x", y: "$$y", rand: "$$rand" }
# Values in "let" must be constant or closed expressions that do not
# depend on document values. This test demonstrates a basic constant
# value, a value wrapped with $literal (to avoid expression parsing),
# and a closed expression (e.g. $rand).
let: &let0
id: 1
x: foo
y: { $literal: "bar" }
rand: { $rand: {} }
expectResult:
- { x: "foo", y: "bar", rand: { $$type: "double" } }
expectEvents:
- client: *client0
events:
- commandStartedEvent:
command:
aggregate: *collection0Name
pipeline: *pipeline0
let: *let0

- description: "Aggregate with let option and dollar-prefixed $literal value"
runOnRequirements:
- minServerVersion: "5.0"
# TODO: Remove topology restrictions once SERVER-57403 is resolved
topologies: ["single", "replicaset"]
operations:
- name: aggregate
object: *collection0
Expand Down
201 changes: 201 additions & 0 deletions test/spec/crud/unified/deleteMany-let.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
{
"description": "deleteMany-let",
dariakp marked this conversation as resolved.
Show resolved Hide resolved
"schemaVersion": "1.0",
"createEntities": [
{
"client": {
"id": "client0",
"observeEvents": [
"commandStartedEvent"
]
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "crud-tests"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "coll0"
}
}
],
"initialData": [
{
"collectionName": "coll0",
"databaseName": "crud-tests",
"documents": [
{
"_id": 1
},
{
"_id": 2,
"name": "name"
},
{
"_id": 3,
"name": "name"
}
]
}
],
"tests": [
{
"description": "deleteMany with let option",
"runOnRequirements": [
{
"minServerVersion": "5.0"
}
],
"operations": [
{
"name": "deleteMany",
"object": "collection0",
"arguments": {
"filter": {
"$expr": {
"$eq": [
"$name",
"$$name"
]
}
},
"let": {
"name": "name"
}
},
"expectResult": {
"deletedCount": 2
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"delete": "coll0",
"deletes": [
{
"q": {
"$expr": {
"$eq": [
"$name",
"$$name"
]
}
},
"limit": 0
}
],
"let": {
"name": "name"
}
}
}
}
]
}
],
"outcome": [
{
"collectionName": "coll0",
"databaseName": "crud-tests",
"documents": [
{
"_id": 1
}
]
}
]
},
{
"description": "deleteMany with let option unsupported (server-side error)",
"runOnRequirements": [
{
"minServerVersion": "3.6.0",
"maxServerVersion": "4.4.99"
}
],
"operations": [
{
"name": "deleteMany",
"object": "collection0",
"arguments": {
"filter": {
"$expr": {
"$eq": [
"$name",
"$$name"
]
}
},
"let": {
"name": "name"
}
},
"expectError": {
"errorContains": "'delete.let' is an unknown field",
"isClientError": false
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"delete": "coll0",
"deletes": [
{
"q": {
"$expr": {
"$eq": [
"$name",
"$$name"
]
}
},
"limit": 0
}
],
"let": {
"name": "name"
}
}
}
}
]
}
],
"outcome": [
{
"collectionName": "coll0",
"databaseName": "crud-tests",
"documents": [
{
"_id": 1
},
{
"_id": 2,
"name": "name"
},
{
"_id": 3,
"name": "name"
}
]
}
]
}
]
}
Loading