From d34a5c19fa36b5ec104ef4e34294cd9bacf07e54 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 18 Jan 2024 10:59:05 +0000 Subject: [PATCH] tests: Reverse position on explicit "must exist" for update --- firestore/v1/update-exists-precond.json | 28 +++++++++++++++++-- firestore/v1/update-paths-exists-precond.json | 28 +++++++++++++++++-- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/firestore/v1/update-exists-precond.json b/firestore/v1/update-exists-precond.json index bdbe274..66e5d11 100644 --- a/firestore/v1/update-exists-precond.json +++ b/firestore/v1/update-exists-precond.json @@ -1,15 +1,37 @@ { "tests": [ { - "description": "update: Exists precondition is invalid", - "comment": "The Update method does not support an explicit exists precondition.", + "description": "update: Exists precondition is valid", + "comment": "The Update method supports an explicit exists precondition.", "update": { "docRefPath": "projects/projectID/databases/(default)/documents/C/d", "precondition": { "exists": true }, "jsonData": "{\"a\": 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": true + } + } + ] + } } } ] diff --git a/firestore/v1/update-paths-exists-precond.json b/firestore/v1/update-paths-exists-precond.json index d495db0..6325c75 100644 --- a/firestore/v1/update-paths-exists-precond.json +++ b/firestore/v1/update-paths-exists-precond.json @@ -1,8 +1,8 @@ { "tests": [ { - "description": "update-paths: Exists precondition is invalid", - "comment": "The Update method does not support an explicit exists precondition.", + "description": "update-paths: Exists precondition is valid", + "comment": "The Update method supports an explicit exists precondition.", "updatePaths": { "docRefPath": "projects/projectID/databases/(default)/documents/C/d", "precondition": { @@ -18,7 +18,29 @@ "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": true + } + } + ] + } } } ]