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: add tests for update with exists=false precondition #84

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions firestore/v1/update-exists-false-precond.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"tests": [
{
"description": "update: Exists=false precondition is valid",
"comment": "The Update method supports an explicit exists=false precondition.",
"update": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"precondition": {
"exists": false
},
"jsonData": "{\"a\": 1}",
"isError": true,
"request": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in chat, let's remove this given that it's meant to be an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"database": "projects/projectID/databases/(default)",
"writes": [
{
"update": {
"name": "projects/projectID/databases/(default)/documents/C/d",
"fields": {
"a": {
"integerValue": "1"
}
}
},
"updateMask": {
"fieldPaths": [
"a"
]
},
"currentDocument": {
"exists": false
}
}
]
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"tests": [
{
"description": "update: Exists precondition is valid",
"comment": "The Update method supports an explicit exists precondition.",
"description": "update: Exists=true precondition is valid",
"comment": "The Update method supports an explicit exists=true precondition.",
"update": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"precondition": {
Expand Down
48 changes: 48 additions & 0 deletions firestore/v1/update-paths-exists-false-precond.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"tests": [
{
"description": "update-paths: Exists=false precondition is valid",
"comment": "The Update method supports an explicit exists=false precondition.",
"updatePaths": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"precondition": {
"exists": false
},
"fieldPaths": [
{
"field": [
"a"
]
}
],
"jsonValues": [
"1"
],
"isError": true,
"request": {
"database": "projects/projectID/databases/(default)",
"writes": [
{
"update": {
"name": "projects/projectID/databases/(default)/documents/C/d",
"fields": {
"a": {
"integerValue": "1"
}
}
},
"updateMask": {
"fieldPaths": [
"a"
]
},
"currentDocument": {
"exists": false
}
}
]
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"tests": [
{
"description": "update-paths: Exists precondition is valid",
"comment": "The Update method supports an explicit exists precondition.",
"description": "update-paths: Exists=true precondition is valid",
"comment": "The Update method supports an explicit exists=true precondition.",
"updatePaths": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"precondition": {
Expand Down