From 76f6165b0a21a8815848127f620d253075d32f7c Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Wed, 23 Sep 2020 14:01:06 -0400 Subject: [PATCH 01/10] tests: rename cross-language tests module to run --- tests/unit/v1/{_test_cross_language.py => test_cross_language.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/unit/v1/{_test_cross_language.py => test_cross_language.py} (100%) diff --git a/tests/unit/v1/_test_cross_language.py b/tests/unit/v1/test_cross_language.py similarity index 100% rename from tests/unit/v1/_test_cross_language.py rename to tests/unit/v1/test_cross_language.py From 1bb29ec937f024fa3be2ecbc8c97f650396e7b63 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Wed, 23 Sep 2020 14:01:32 -0400 Subject: [PATCH 02/10] chore: drop v1beta1 makefile --- Makefile_v1beta1 | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 Makefile_v1beta1 diff --git a/Makefile_v1beta1 b/Makefile_v1beta1 deleted file mode 100644 index 69cf87f41a..0000000000 --- a/Makefile_v1beta1 +++ /dev/null @@ -1,37 +0,0 @@ -# This makefile builds the protos needed for cross-language Firestore tests. - -# Assume protoc is on the path. The proto compiler must be one that -# supports proto3 syntax. -PROTOC = protoc - -# Dependent repos. -REPO_DIR = $(HOME)/git-repos -PROTOBUF_REPO = $(REPO_DIR)/protobuf -GOOGLEAPIS_REPO = $(REPO_DIR)/googleapis -TESTS_REPO = $(REPO_DIR)/gcp/google-cloud-common - -TMPDIR = /tmp/python-fs-proto -TMPDIR_FS = $(TMPDIR)/google/cloud/firestore_v1beta1/proto - -.PHONY: sync-protos gen-protos - -gen-protos: sync-protos tweak-protos - # TODO(jba): Put the generated proto somewhere more suitable. - $(PROTOC) --python_out=google/cloud/firestore_v1beta1/proto \ - -I $(TMPDIR) \ - -I $(PROTOBUF_REPO)/src \ - -I $(GOOGLEAPIS_REPO) \ - $(TMPDIR)/test_v1beta1.proto - -tweak-protos: - mkdir -p $(TMPDIR_FS) - cp $(GOOGLEAPIS_REPO)/google/firestore/v1beta1/*.proto $(TMPDIR_FS) - sed -i -e 's@google/firestore/v1beta1@google/cloud/firestore_v1beta1/proto@' $(TMPDIR_FS)/*.proto - cp $(TESTS_REPO)/testing/firestore/proto/test_v1beta1.proto $(TMPDIR) - sed -i -e 's@package tests@package tests.v1beta1@' $(TMPDIR)/test_v1beta1.proto - sed -i -e 's@google/firestore/v1beta1@google/cloud/firestore_v1beta1/proto@' $(TMPDIR)/test_v1beta1.proto - -sync-protos: - cd $(PROTOBUF_REPO); git pull - cd $(GOOGLEAPIS_REPO); git pull - #cd $(TESTS_REPO); git pull From 29faa4ed1bc38b643fa0ece1173bbeb78225880a Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Wed, 23 Sep 2020 15:12:30 -0400 Subject: [PATCH 03/10] chore: generate conftest messages using gapic-generator-python --- Makefile_v1 | 37 +- google/cloud/firestore_v1/types/tests.py | 602 +++++++++++++++++++++++ 2 files changed, 627 insertions(+), 12 deletions(-) create mode 100644 google/cloud/firestore_v1/types/tests.py diff --git a/Makefile_v1 b/Makefile_v1 index af193e3e81..6ab1fa2dbc 100644 --- a/Makefile_v1 +++ b/Makefile_v1 @@ -11,30 +11,43 @@ GOOGLEAPIS_REPO = $(REPO_DIR)/googleapis TESTS_REPO = $(REPO_DIR)/conformance-tests TEST_PROTO_DIR = $(TESTS_REPO)/firestore/v1 TEST_PROTO_SRC = $(TEST_PROTO_DIR)/proto/google/cloud/conformance/firestore/v1/tests.proto +TESTDATA_DIR = tests/unit/vi/testdata TMPDIR = /tmp/python-fs-proto -TMPDIR_FS = $(TMPDIR)/google/cloud/firestore_v1/proto +TMPDIR_FS = $(TMPDIR)/google/cloud/firestore_v1/types TEST_PROTO_COPY = $(TMPDIR_FS)/tests.proto +OUTDIR = /tmp/python-fs-gen -.PHONY: sync-protos gen-protos +.PHONY: sync-protos gen-protos docker-pull -gen-protos: sync-protos tweak-protos - # TODO(jba): Put the generated proto somewhere more suitable. - $(PROTOC) --python_out=. \ - -I $(TMPDIR) \ - -I $(PROTOBUF_REPO)/src \ - -I $(GOOGLEAPIS_REPO) \ - $(TEST_PROTO_COPY) +gen-protos: sync-protos tweak-protos docker-pull gen-protos-raw + +gen-protos-raw: + mkdir -p $(OUTDIR) + docker run \ + --mount type=bind,source=$(TMPDIR),destination="/in",readonly \ + --mount type=bind,source=$(OUTDIR),destination="/out" \ + --rm \ + --user `id -u`:`id -g` \ + gcr.io/gapic-images/gapic-generator-python + cp $(OUTDIR)/google/cloud/firestore_v1/types/tests.py \ + google/cloud/firestore_v1/types/ tweak-protos: mkdir -p $(TMPDIR_FS) cp $(GOOGLEAPIS_REPO)/google/firestore/v1/*.proto $(TMPDIR_FS) - sed -i -e 's@google/firestore/v1@google/cloud/firestore_v1/proto@' $(TMPDIR_FS)/*.proto + sed -i -e 's@google/firestore/v1@google/cloud/firestore_v1/types@' $(TMPDIR_FS)/*.proto + sed -i -e 's@package google\.firestore\.v1@package google.cloud.firestore_v1@' $(TMPDIR_FS)/*.proto cp $(TEST_PROTO_SRC) $(TEST_PROTO_COPY) - sed -i -e 's@package google.cloud.conformance.firestore.v1@package google.cloud.firestore_v1.proto@' $(TEST_PROTO_COPY) - sed -i -e 's@google/firestore/v1@google/cloud/firestore_v1/proto@' $(TEST_PROTO_COPY) + sed -i -e 's@package google\.cloud\.conformance\.firestore\.v1@package google.cloud.firestore_v1@' $(TEST_PROTO_COPY) + sed -i -e 's@google/firestore/v1@google/cloud/firestore_v1/types@' $(TEST_PROTO_COPY) + sed -i -e 's@google\.firestore\.v1@google.cloud.firestore_v1@' $(TEST_PROTO_COPY) + sed -i -e 's@Cursor@Cursor_@' $(TEST_PROTO_COPY) sync-protos: cd $(PROTOBUF_REPO); git pull cd $(GOOGLEAPIS_REPO); git pull cd $(TESTS_REPO); git pull + +docker-pull: + docker pull gcr.io/gapic-images/gapic-generator-python:latest diff --git a/google/cloud/firestore_v1/types/tests.py b/google/cloud/firestore_v1/types/tests.py new file mode 100644 index 0000000000..933aa93704 --- /dev/null +++ b/google/cloud/firestore_v1/types/tests.py @@ -0,0 +1,602 @@ +# -*- coding: utf-8 -*- + +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import proto # type: ignore + + +from google.cloud.firestore_v1.types import common +from google.cloud.firestore_v1.types import document +from google.cloud.firestore_v1.types import firestore +from google.cloud.firestore_v1.types import query as gcf_query +from google.protobuf import timestamp_pb2 as timestamp # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.firestore_v1', + manifest={ + 'TestFile', + 'Test', + 'GetTest', + 'CreateTest', + 'SetTest', + 'UpdateTest', + 'UpdatePathsTest', + 'DeleteTest', + 'SetOption', + 'QueryTest', + 'Clause', + 'Select', + 'Where', + 'OrderBy', + 'Cursor_', + 'DocSnapshot', + 'FieldPath', + 'ListenTest', + 'Snapshot', + 'DocChange', + }, +) + + +class TestFile(proto.Message): + r"""A collection of tests. + + Attributes: + tests (Sequence[~.gcf_tests.Test]): + + """ + + tests = proto.RepeatedField(proto.MESSAGE, number=1, + message='Test', + ) + + +class Test(proto.Message): + r"""A Test describes a single client method call and its expected + result. + + Attributes: + description (str): + short description of the test + comment (str): + a comment describing the behavior being + tested + get (~.gcf_tests.GetTest): + + create (~.gcf_tests.CreateTest): + + set_ (~.gcf_tests.SetTest): + + update (~.gcf_tests.UpdateTest): + + update_paths (~.gcf_tests.UpdatePathsTest): + + delete (~.gcf_tests.DeleteTest): + + query (~.gcf_tests.QueryTest): + + listen (~.gcf_tests.ListenTest): + + """ + + description = proto.Field(proto.STRING, number=1) + + comment = proto.Field(proto.STRING, number=10) + + get = proto.Field(proto.MESSAGE, number=2, oneof='test', + message='GetTest', + ) + + create = proto.Field(proto.MESSAGE, number=3, oneof='test', + message='CreateTest', + ) + + set_ = proto.Field(proto.MESSAGE, number=4, oneof='test', + message='SetTest', + ) + + update = proto.Field(proto.MESSAGE, number=5, oneof='test', + message='UpdateTest', + ) + + update_paths = proto.Field(proto.MESSAGE, number=6, oneof='test', + message='UpdatePathsTest', + ) + + delete = proto.Field(proto.MESSAGE, number=7, oneof='test', + message='DeleteTest', + ) + + query = proto.Field(proto.MESSAGE, number=8, oneof='test', + message='QueryTest', + ) + + listen = proto.Field(proto.MESSAGE, number=9, oneof='test', + message='ListenTest', + ) + + +class GetTest(proto.Message): + r"""Call to the DocumentRef.Get method. + + Attributes: + doc_ref_path (str): + The path of the doc, e.g. + "projects/projectID/databases/(default)/documents/C/d". + request (~.firestore.GetDocumentRequest): + The request that the call should send to the + Firestore service. + """ + + doc_ref_path = proto.Field(proto.STRING, number=1) + + request = proto.Field(proto.MESSAGE, number=2, + message=firestore.GetDocumentRequest, + ) + + +class CreateTest(proto.Message): + r"""Call to DocumentRef.Create. + + Attributes: + doc_ref_path (str): + The path of the doc, e.g. + "projects/projectID/databases/(default)/documents/C/d". + json_data (str): + The data passed to Create, as JSON. The + strings "Delete" and "ServerTimestamp" denote + the two special sentinel values. Values that + could be interpreted as integers (i.e. digit + strings) should be treated as integers. + request (~.firestore.CommitRequest): + The request that the call should generate. + is_error (bool): + If true, the call should result in an error + without generating a request. If this is true, + request should not be set. + """ + + doc_ref_path = proto.Field(proto.STRING, number=1) + + json_data = proto.Field(proto.STRING, number=2) + + request = proto.Field(proto.MESSAGE, number=3, + message=firestore.CommitRequest, + ) + + is_error = proto.Field(proto.BOOL, number=4) + + +class SetTest(proto.Message): + r"""A call to DocumentRef.Set. + + Attributes: + doc_ref_path (str): + path of doc + option (~.gcf_tests.SetOption): + option to the Set call, if any + json_data (str): + data (see CreateTest.json_data) + request (~.firestore.CommitRequest): + expected request + is_error (bool): + call signals an error + """ + + doc_ref_path = proto.Field(proto.STRING, number=1) + + option = proto.Field(proto.MESSAGE, number=2, + message='SetOption', + ) + + json_data = proto.Field(proto.STRING, number=3) + + request = proto.Field(proto.MESSAGE, number=4, + message=firestore.CommitRequest, + ) + + is_error = proto.Field(proto.BOOL, number=5) + + +class UpdateTest(proto.Message): + r"""A call to the form of DocumentRef.Update that represents the + data as a map or dictionary. + + Attributes: + doc_ref_path (str): + path of doc + precondition (~.common.Precondition): + precondition in call, if any + json_data (str): + data (see CreateTest.json_data) + request (~.firestore.CommitRequest): + expected request + is_error (bool): + call signals an error + """ + + doc_ref_path = proto.Field(proto.STRING, number=1) + + precondition = proto.Field(proto.MESSAGE, number=2, + message=common.Precondition, + ) + + json_data = proto.Field(proto.STRING, number=3) + + request = proto.Field(proto.MESSAGE, number=4, + message=firestore.CommitRequest, + ) + + is_error = proto.Field(proto.BOOL, number=5) + + +class UpdatePathsTest(proto.Message): + r"""A call to the form of DocumentRef.Update that represents the + data as a list of field paths and their values. + + Attributes: + doc_ref_path (str): + path of doc + precondition (~.common.Precondition): + precondition in call, if any + field_paths (Sequence[~.gcf_tests.FieldPath]): + parallel sequences: field_paths[i] corresponds to + json_values[i] + json_values (Sequence[str]): + the argument values, as JSON + request (~.firestore.CommitRequest): + expected rquest + is_error (bool): + call signals an error + """ + + doc_ref_path = proto.Field(proto.STRING, number=1) + + precondition = proto.Field(proto.MESSAGE, number=2, + message=common.Precondition, + ) + + field_paths = proto.RepeatedField(proto.MESSAGE, number=3, + message='FieldPath', + ) + + json_values = proto.RepeatedField(proto.STRING, number=4) + + request = proto.Field(proto.MESSAGE, number=5, + message=firestore.CommitRequest, + ) + + is_error = proto.Field(proto.BOOL, number=6) + + +class DeleteTest(proto.Message): + r"""A call to DocmentRef.Delete + + Attributes: + doc_ref_path (str): + path of doc + precondition (~.common.Precondition): + + request (~.firestore.CommitRequest): + expected rquest + is_error (bool): + call signals an error + """ + + doc_ref_path = proto.Field(proto.STRING, number=1) + + precondition = proto.Field(proto.MESSAGE, number=2, + message=common.Precondition, + ) + + request = proto.Field(proto.MESSAGE, number=3, + message=firestore.CommitRequest, + ) + + is_error = proto.Field(proto.BOOL, number=4) + + +class SetOption(proto.Message): + r"""An option to the DocumentRef.Set call. + + Attributes: + all_ (bool): + if true, merge all fields ("fields" is + ignored). + fields (Sequence[~.gcf_tests.FieldPath]): + field paths for a Merge option + """ + + all_ = proto.Field(proto.BOOL, number=1) + + fields = proto.RepeatedField(proto.MESSAGE, number=2, + message='FieldPath', + ) + + +class QueryTest(proto.Message): + r""" + + Attributes: + coll_path (str): + path of collection, e.g. + "projects/projectID/databases/(default)/documents/C". + clauses (Sequence[~.gcf_tests.Clause]): + + query (~.gcf_query.StructuredQuery): + + is_error (bool): + + """ + + coll_path = proto.Field(proto.STRING, number=1) + + clauses = proto.RepeatedField(proto.MESSAGE, number=2, + message='Clause', + ) + + query = proto.Field(proto.MESSAGE, number=3, + message=gcf_query.StructuredQuery, + ) + + is_error = proto.Field(proto.BOOL, number=4) + + +class Clause(proto.Message): + r""" + + Attributes: + select (~.gcf_tests.Select): + + where (~.gcf_tests.Where): + + order_by (~.gcf_tests.OrderBy): + + offset (int): + + limit (int): + + start_at (~.gcf_tests.Cursor_): + + start_after (~.gcf_tests.Cursor_): + + end_at (~.gcf_tests.Cursor_): + + end_before (~.gcf_tests.Cursor_): + + """ + + select = proto.Field(proto.MESSAGE, number=1, oneof='clause', + message='Select', + ) + + where = proto.Field(proto.MESSAGE, number=2, oneof='clause', + message='Where', + ) + + order_by = proto.Field(proto.MESSAGE, number=3, oneof='clause', + message='OrderBy', + ) + + offset = proto.Field(proto.INT32, number=4, oneof='clause') + + limit = proto.Field(proto.INT32, number=5, oneof='clause') + + start_at = proto.Field(proto.MESSAGE, number=6, oneof='clause', + message='Cursor_', + ) + + start_after = proto.Field(proto.MESSAGE, number=7, oneof='clause', + message='Cursor_', + ) + + end_at = proto.Field(proto.MESSAGE, number=8, oneof='clause', + message='Cursor_', + ) + + end_before = proto.Field(proto.MESSAGE, number=9, oneof='clause', + message='Cursor_', + ) + + +class Select(proto.Message): + r""" + + Attributes: + fields (Sequence[~.gcf_tests.FieldPath]): + + """ + + fields = proto.RepeatedField(proto.MESSAGE, number=1, + message='FieldPath', + ) + + +class Where(proto.Message): + r""" + + Attributes: + path (~.gcf_tests.FieldPath): + + op (str): + + json_value (str): + + """ + + path = proto.Field(proto.MESSAGE, number=1, + message='FieldPath', + ) + + op = proto.Field(proto.STRING, number=2) + + json_value = proto.Field(proto.STRING, number=3) + + +class OrderBy(proto.Message): + r""" + + Attributes: + path (~.gcf_tests.FieldPath): + + direction (str): + "asc" or "desc". + """ + + path = proto.Field(proto.MESSAGE, number=1, + message='FieldPath', + ) + + direction = proto.Field(proto.STRING, number=2) + + +class Cursor_(proto.Message): + r""" + + Attributes: + doc_snapshot (~.gcf_tests.DocSnapshot): + one of: + json_values (Sequence[str]): + + """ + + doc_snapshot = proto.Field(proto.MESSAGE, number=1, + message='DocSnapshot', + ) + + json_values = proto.RepeatedField(proto.STRING, number=2) + + +class DocSnapshot(proto.Message): + r""" + + Attributes: + path (str): + + json_data (str): + + """ + + path = proto.Field(proto.STRING, number=1) + + json_data = proto.Field(proto.STRING, number=2) + + +class FieldPath(proto.Message): + r""" + + Attributes: + field (Sequence[str]): + + """ + + field = proto.RepeatedField(proto.STRING, number=1) + + +class ListenTest(proto.Message): + r"""A test of the Listen streaming RPC (a.k.a. FireStore watch). If the + sequence of responses is provided to the implementation, it should + produce the sequence of snapshots. If is_error is true, an error + should occur after the snapshots. + + The tests assume that the query is + Collection("projects/projectID/databases/(default)/documents/C").OrderBy("a", + Ascending) + + The watch target ID used in these tests is 1. Test interpreters + should either change their client's ID for testing, or change the ID + in the tests before running them. + + Attributes: + responses (Sequence[~.firestore.ListenResponse]): + + snapshots (Sequence[~.gcf_tests.Snapshot]): + + is_error (bool): + + """ + + responses = proto.RepeatedField(proto.MESSAGE, number=1, + message=firestore.ListenResponse, + ) + + snapshots = proto.RepeatedField(proto.MESSAGE, number=2, + message='Snapshot', + ) + + is_error = proto.Field(proto.BOOL, number=3) + + +class Snapshot(proto.Message): + r""" + + Attributes: + docs (Sequence[~.document.Document]): + + changes (Sequence[~.gcf_tests.DocChange]): + + read_time (~.timestamp.Timestamp): + + """ + + docs = proto.RepeatedField(proto.MESSAGE, number=1, + message=document.Document, + ) + + changes = proto.RepeatedField(proto.MESSAGE, number=2, + message='DocChange', + ) + + read_time = proto.Field(proto.MESSAGE, number=3, + message=timestamp.Timestamp, + ) + + +class DocChange(proto.Message): + r""" + + Attributes: + kind (~.gcf_tests.DocChange.Kind): + + doc (~.document.Document): + + old_index (int): + + new_index (int): + + """ + class Kind(proto.Enum): + r"""""" + KIND_UNSPECIFIED = 0 + ADDED = 1 + REMOVED = 2 + MODIFIED = 3 + + kind = proto.Field(proto.ENUM, number=1, + enum=Kind, + ) + + doc = proto.Field(proto.MESSAGE, number=2, + message=document.Document, + ) + + old_index = proto.Field(proto.INT32, number=3) + + new_index = proto.Field(proto.INT32, number=4) + + +__all__ = tuple(sorted(__protobuf__.manifest)) From 143a7dc2d6aa2f57ad383112cd01fd39b6dc9458 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Thu, 24 Sep 2020 22:00:40 -0400 Subject: [PATCH 04/10] chore: update conftest parsing to accomodate proto-plus --- tests/unit/v1/test_cross_language.py | 49 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/tests/unit/v1/test_cross_language.py b/tests/unit/v1/test_cross_language.py index 10fece5eb0..0956917fce 100644 --- a/tests/unit/v1/test_cross_language.py +++ b/tests/unit/v1/test_cross_language.py @@ -25,16 +25,18 @@ from google.protobuf import json_format from google.cloud.firestore_v1.types import document from google.cloud.firestore_v1.types import firestore -from google.cloud.firestore_v1.proto import tests_pb2 +from google.cloud.firestore_v1.types import tests from google.cloud.firestore_v1.types import write def _load_test_json(filename): - with open(filename, "r") as tp_file: - tp_json = json.load(tp_file) - test_file = tests_pb2.TestFile() - json_format.ParseDict(tp_json, test_file) shortname = os.path.split(filename)[-1] + + with open(filename, "r") as tp_file: + tp_json = tp_file.read() + + test_file = tests.TestFile.from_json(tp_json) + for test_proto in test_file.tests: test_proto.description = test_proto.description + " (%s)" % shortname yield test_proto @@ -50,49 +52,49 @@ def _load_test_json(filename): _CREATE_TESTPROTOS = [ test_proto for test_proto in ALL_TESTPROTOS - if test_proto.WhichOneof("test") == "create" + if "create" in test_proto ] _GET_TESTPROTOS = [ test_proto for test_proto in ALL_TESTPROTOS - if test_proto.WhichOneof("test") == "get" + if "get" in test_proto ] _SET_TESTPROTOS = [ test_proto for test_proto in ALL_TESTPROTOS - if test_proto.WhichOneof("test") == "set" + if "set_" in test_proto ] _UPDATE_TESTPROTOS = [ test_proto for test_proto in ALL_TESTPROTOS - if test_proto.WhichOneof("test") == "update" + if "update" in test_proto ] _UPDATE_PATHS_TESTPROTOS = [ test_proto for test_proto in ALL_TESTPROTOS - if test_proto.WhichOneof("test") == "update_paths" + if "update_paths" in test_proto ] _DELETE_TESTPROTOS = [ test_proto for test_proto in ALL_TESTPROTOS - if test_proto.WhichOneof("test") == "delete" + if "delete" in test_proto ] _LISTEN_TESTPROTOS = [ test_proto for test_proto in ALL_TESTPROTOS - if test_proto.WhichOneof("test") == "listen" + if "listen" in test_proto ] _QUERY_TESTPROTOS = [ test_proto for test_proto in ALL_TESTPROTOS - if test_proto.WhichOneof("test") == "query" + if "query" in test_proto ] @@ -454,40 +456,39 @@ def parse_query(testcase): query = collection for clause in testcase.clauses: - kind = clause.WhichOneof("clause") - if kind == "select": + if "select" in clause: field_paths = [ ".".join(field_path.field) for field_path in clause.select.fields ] query = query.select(field_paths) - elif kind == "where": + elif "where" in clause: path = ".".join(clause.where.path.field) value = convert_data(json.loads(clause.where.json_value)) query = query.where(path, clause.where.op, value) - elif kind == "order_by": + elif "order_by" in clause: path = ".".join(clause.order_by.path.field) direction = clause.order_by.direction direction = _directions.get(direction, direction) query = query.order_by(path, direction=direction) - elif kind == "offset": + elif "offset" in clause: query = query.offset(clause.offset) - elif kind == "limit": + elif "limit" in clause: query = query.limit(clause.limit) - elif kind == "start_at": + elif "start_at" in clause: cursor = parse_cursor(clause.start_at, client) query = query.start_at(cursor) - elif kind == "start_after": + elif "start_after" in clause: cursor = parse_cursor(clause.start_after, client) query = query.start_after(cursor) - elif kind == "end_at": + elif "end_at" in clause: cursor = parse_cursor(clause.end_at, client) query = query.end_at(cursor) - elif kind == "end_before": + elif "end_before" in clause: cursor = parse_cursor(clause.end_before, client) query = query.end_before(cursor) else: # pragma: NO COVER - raise ValueError("Unknown query clause: {}".format(kind)) + raise ValueError("Unknown query clause: {}".format(clause)) return query From 9cdd1a47e10d2d91bca0b01a12de78d52b42a5ba Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Thu, 24 Sep 2020 22:03:14 -0400 Subject: [PATCH 05/10] chore: copy in latest version of conftests from upstream repo Add a rule to the makefile to make it easier in the future to update them --- Makefile_v1 | 6 +- .../v1/testdata/create-all-transforms.json | 81 +++++++++---------- .../v1/testdata/create-arrayremove-multi.json | 73 ++++++++--------- .../testdata/create-arrayremove-nested.json | 41 +++++----- .../unit/v1/testdata/create-arrayremove.json | 41 +++++----- .../v1/testdata/create-arrayunion-multi.json | 73 ++++++++--------- .../v1/testdata/create-arrayunion-nested.json | 41 +++++----- tests/unit/v1/testdata/create-arrayunion.json | 41 +++++----- tests/unit/v1/testdata/create-st-alone.json | 21 ++--- tests/unit/v1/testdata/create-st-multi.json | 27 +++---- tests/unit/v1/testdata/create-st-nested.json | 19 ++--- .../v1/testdata/create-st-with-empty-map.json | 19 ++--- tests/unit/v1/testdata/create-st.json | 19 ++--- .../unit/v1/testdata/set-all-transforms.json | 81 +++++++++---------- .../v1/testdata/set-arrayremove-multi.json | 73 ++++++++--------- .../v1/testdata/set-arrayremove-nested.json | 41 +++++----- tests/unit/v1/testdata/set-arrayremove.json | 41 +++++----- .../v1/testdata/set-arrayunion-multi.json | 73 ++++++++--------- .../v1/testdata/set-arrayunion-nested.json | 41 +++++----- tests/unit/v1/testdata/set-arrayunion.json | 41 +++++----- .../v1/testdata/set-st-alone-mergeall.json | 22 ++--- tests/unit/v1/testdata/set-st-alone.json | 19 ++--- tests/unit/v1/testdata/set-st-merge-both.json | 19 ++--- .../testdata/set-st-merge-nonleaf-alone.json | 19 ++--- .../v1/testdata/set-st-merge-nonleaf.json | 19 ++--- .../v1/testdata/set-st-merge-nowrite.json | 22 ++--- tests/unit/v1/testdata/set-st-mergeall.json | 19 ++--- tests/unit/v1/testdata/set-st-multi.json | 27 +++---- tests/unit/v1/testdata/set-st-nested.json | 19 ++--- .../v1/testdata/set-st-with-empty-map.json | 19 ++--- tests/unit/v1/testdata/set-st.json | 19 ++--- .../v1/testdata/update-all-transforms.json | 81 +++++++++---------- .../v1/testdata/update-arrayremove-alone.json | 50 ++++++------ .../v1/testdata/update-arrayremove-multi.json | 73 ++++++++--------- .../testdata/update-arrayremove-nested.json | 41 +++++----- .../unit/v1/testdata/update-arrayremove.json | 41 +++++----- .../v1/testdata/update-arrayunion-alone.json | 48 ++++++----- .../v1/testdata/update-arrayunion-multi.json | 73 ++++++++--------- .../v1/testdata/update-arrayunion-nested.json | 41 +++++----- tests/unit/v1/testdata/update-arrayunion.json | 41 +++++----- ...ate-nested-transform-and-nested-value.json | 19 ++--- .../testdata/update-paths-all-transforms.json | 81 +++++++++---------- .../update-paths-arrayremove-alone.json | 48 ++++++----- .../update-paths-arrayremove-multi.json | 73 ++++++++--------- .../update-paths-arrayremove-nested.json | 41 +++++----- .../v1/testdata/update-paths-arrayremove.json | 41 +++++----- .../update-paths-arrayunion-alone.json | 48 ++++++----- .../update-paths-arrayunion-multi.json | 73 ++++++++--------- .../update-paths-arrayunion-nested.json | 41 +++++----- .../v1/testdata/update-paths-arrayunion.json | 41 +++++----- ...ths-nested-transform-and-nested-value.json | 19 ++--- .../v1/testdata/update-paths-st-alone.json | 24 +++--- .../v1/testdata/update-paths-st-multi.json | 27 +++---- .../v1/testdata/update-paths-st-nested.json | 19 ++--- .../update-paths-st-with-empty-map.json | 17 ++-- tests/unit/v1/testdata/update-paths-st.json | 19 ++--- tests/unit/v1/testdata/update-st-alone.json | 24 +++--- tests/unit/v1/testdata/update-st-dot.json | 24 +++--- tests/unit/v1/testdata/update-st-multi.json | 27 +++---- tests/unit/v1/testdata/update-st-nested.json | 19 ++--- .../v1/testdata/update-st-with-empty-map.json | 19 ++--- tests/unit/v1/testdata/update-st.json | 19 ++--- 62 files changed, 1077 insertions(+), 1291 deletions(-) diff --git a/Makefile_v1 b/Makefile_v1 index 6ab1fa2dbc..eb783031ca 100644 --- a/Makefile_v1 +++ b/Makefile_v1 @@ -11,7 +11,7 @@ GOOGLEAPIS_REPO = $(REPO_DIR)/googleapis TESTS_REPO = $(REPO_DIR)/conformance-tests TEST_PROTO_DIR = $(TESTS_REPO)/firestore/v1 TEST_PROTO_SRC = $(TEST_PROTO_DIR)/proto/google/cloud/conformance/firestore/v1/tests.proto -TESTDATA_DIR = tests/unit/vi/testdata +TESTDATA_DIR = `pwd`/tests/unit/v1/testdata/ TMPDIR = /tmp/python-fs-proto TMPDIR_FS = $(TMPDIR)/google/cloud/firestore_v1/types @@ -51,3 +51,7 @@ sync-protos: docker-pull: docker pull gcr.io/gapic-images/gapic-generator-python:latest + +copy-testdata: + rm $(TESTDATA_DIR)/*.json + cp $(TEST_PROTO_DIR)/*.json $(TESTDATA_DIR)/ diff --git a/tests/unit/v1/testdata/create-all-transforms.json b/tests/unit/v1/testdata/create-all-transforms.json index 82831624bb..6389599987 100644 --- a/tests/unit/v1/testdata/create-all-transforms.json +++ b/tests/unit/v1/testdata/create-all-transforms.json @@ -20,50 +20,45 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-arrayremove-multi.json b/tests/unit/v1/testdata/create-arrayremove-multi.json index 548a983808..331a53bf9c 100644 --- a/tests/unit/v1/testdata/create-arrayremove-multi.json +++ b/tests/unit/v1/testdata/create-arrayremove-multi.json @@ -20,46 +20,41 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-arrayremove-nested.json b/tests/unit/v1/testdata/create-arrayremove-nested.json index fa01bd7e00..00c73d05cc 100644 --- a/tests/unit/v1/testdata/create-arrayremove-nested.json +++ b/tests/unit/v1/testdata/create-arrayremove-nested.json @@ -20,30 +20,25 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-arrayremove.json b/tests/unit/v1/testdata/create-arrayremove.json index a69be14b7b..646e259f6f 100644 --- a/tests/unit/v1/testdata/create-arrayremove.json +++ b/tests/unit/v1/testdata/create-arrayremove.json @@ -20,30 +20,25 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-arrayunion-multi.json b/tests/unit/v1/testdata/create-arrayunion-multi.json index 7ca9852f48..5ba324f429 100644 --- a/tests/unit/v1/testdata/create-arrayunion-multi.json +++ b/tests/unit/v1/testdata/create-arrayunion-multi.json @@ -20,46 +20,41 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-arrayunion-nested.json b/tests/unit/v1/testdata/create-arrayunion-nested.json index a2f20299d3..2a21509004 100644 --- a/tests/unit/v1/testdata/create-arrayunion-nested.json +++ b/tests/unit/v1/testdata/create-arrayunion-nested.json @@ -20,30 +20,25 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-arrayunion.json b/tests/unit/v1/testdata/create-arrayunion.json index 26d0799466..99a75feded 100644 --- a/tests/unit/v1/testdata/create-arrayunion.json +++ b/tests/unit/v1/testdata/create-arrayunion.json @@ -20,30 +20,25 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-st-alone.json b/tests/unit/v1/testdata/create-st-alone.json index 20c5e8ec32..177293906b 100644 --- a/tests/unit/v1/testdata/create-st-alone.json +++ b/tests/unit/v1/testdata/create-st-alone.json @@ -10,18 +10,19 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - }, "currentDocument": { "exists": false - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-st-multi.json b/tests/unit/v1/testdata/create-st-multi.json index 89430e2b64..41f3cd811c 100644 --- a/tests/unit/v1/testdata/create-st-multi.json +++ b/tests/unit/v1/testdata/create-st-multi.json @@ -20,22 +20,17 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-st-nested.json b/tests/unit/v1/testdata/create-st-nested.json index f2a3a8d1f6..7316d916f4 100644 --- a/tests/unit/v1/testdata/create-st-nested.json +++ b/tests/unit/v1/testdata/create-st-nested.json @@ -20,18 +20,13 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-st-with-empty-map.json b/tests/unit/v1/testdata/create-st-with-empty-map.json index 730afd154f..b638a0c9db 100644 --- a/tests/unit/v1/testdata/create-st-with-empty-map.json +++ b/tests/unit/v1/testdata/create-st-with-empty-map.json @@ -28,18 +28,13 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/create-st.json b/tests/unit/v1/testdata/create-st.json index 705f76ed16..c4ad4be46b 100644 --- a/tests/unit/v1/testdata/create-st.json +++ b/tests/unit/v1/testdata/create-st.json @@ -20,18 +20,13 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-all-transforms.json b/tests/unit/v1/testdata/set-all-transforms.json index 5c8b1373d4..a26b51b007 100644 --- a/tests/unit/v1/testdata/set-all-transforms.json +++ b/tests/unit/v1/testdata/set-all-transforms.json @@ -17,50 +17,45 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-arrayremove-multi.json b/tests/unit/v1/testdata/set-arrayremove-multi.json index 3ea9b0dbd8..dc2ace22f8 100644 --- a/tests/unit/v1/testdata/set-arrayremove-multi.json +++ b/tests/unit/v1/testdata/set-arrayremove-multi.json @@ -17,46 +17,41 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-arrayremove-nested.json b/tests/unit/v1/testdata/set-arrayremove-nested.json index 4db133f2c5..1e25b8f26b 100644 --- a/tests/unit/v1/testdata/set-arrayremove-nested.json +++ b/tests/unit/v1/testdata/set-arrayremove-nested.json @@ -17,30 +17,25 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-arrayremove.json b/tests/unit/v1/testdata/set-arrayremove.json index 18969ef80a..e0506b22be 100644 --- a/tests/unit/v1/testdata/set-arrayremove.json +++ b/tests/unit/v1/testdata/set-arrayremove.json @@ -17,30 +17,25 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-arrayunion-multi.json b/tests/unit/v1/testdata/set-arrayunion-multi.json index 3d076397c5..502d7dc7df 100644 --- a/tests/unit/v1/testdata/set-arrayunion-multi.json +++ b/tests/unit/v1/testdata/set-arrayunion-multi.json @@ -17,46 +17,41 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-arrayunion-nested.json b/tests/unit/v1/testdata/set-arrayunion-nested.json index e265f6c613..7084e6bcd9 100644 --- a/tests/unit/v1/testdata/set-arrayunion-nested.json +++ b/tests/unit/v1/testdata/set-arrayunion-nested.json @@ -17,30 +17,25 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-arrayunion.json b/tests/unit/v1/testdata/set-arrayunion.json index 856e075173..af12b33dd0 100644 --- a/tests/unit/v1/testdata/set-arrayunion.json +++ b/tests/unit/v1/testdata/set-arrayunion.json @@ -17,30 +17,25 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-alone-mergeall.json b/tests/unit/v1/testdata/set-st-alone-mergeall.json index d95bf0973b..f6b60af810 100644 --- a/tests/unit/v1/testdata/set-st-alone-mergeall.json +++ b/tests/unit/v1/testdata/set-st-alone-mergeall.json @@ -13,15 +13,19 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - } + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-alone.json b/tests/unit/v1/testdata/set-st-alone.json index 3fe931394b..1d28fd6f18 100644 --- a/tests/unit/v1/testdata/set-st-alone.json +++ b/tests/unit/v1/testdata/set-st-alone.json @@ -13,18 +13,13 @@ "update": { "name": "projects/projectID/databases/(default)/documents/C/d", "fields": {} - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-merge-both.json b/tests/unit/v1/testdata/set-st-merge-both.json index a39ada55f7..359c899a1e 100644 --- a/tests/unit/v1/testdata/set-st-merge-both.json +++ b/tests/unit/v1/testdata/set-st-merge-both.json @@ -36,18 +36,13 @@ "fieldPaths": [ "a" ] - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-merge-nonleaf-alone.json b/tests/unit/v1/testdata/set-st-merge-nonleaf-alone.json index 4193b00ea6..5af99ab0a5 100644 --- a/tests/unit/v1/testdata/set-st-merge-nonleaf-alone.json +++ b/tests/unit/v1/testdata/set-st-merge-nonleaf-alone.json @@ -26,18 +26,13 @@ "fieldPaths": [ "h" ] - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "h.g", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "h.g", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-merge-nonleaf.json b/tests/unit/v1/testdata/set-st-merge-nonleaf.json index 5e91d663b8..e66ca87bf8 100644 --- a/tests/unit/v1/testdata/set-st-merge-nonleaf.json +++ b/tests/unit/v1/testdata/set-st-merge-nonleaf.json @@ -37,18 +37,13 @@ "fieldPaths": [ "h" ] - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "h.g", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "h.g", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-merge-nowrite.json b/tests/unit/v1/testdata/set-st-merge-nowrite.json index 08fa8b52f5..44091b1276 100644 --- a/tests/unit/v1/testdata/set-st-merge-nowrite.json +++ b/tests/unit/v1/testdata/set-st-merge-nowrite.json @@ -19,15 +19,19 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-mergeall.json b/tests/unit/v1/testdata/set-st-mergeall.json index 26883c0382..f913d69e61 100644 --- a/tests/unit/v1/testdata/set-st-mergeall.json +++ b/tests/unit/v1/testdata/set-st-mergeall.json @@ -25,18 +25,13 @@ "fieldPaths": [ "a" ] - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-multi.json b/tests/unit/v1/testdata/set-st-multi.json index 23c06f4976..03200729ca 100644 --- a/tests/unit/v1/testdata/set-st-multi.json +++ b/tests/unit/v1/testdata/set-st-multi.json @@ -17,22 +17,17 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-nested.json b/tests/unit/v1/testdata/set-st-nested.json index 5c94c33f94..58406e80b3 100644 --- a/tests/unit/v1/testdata/set-st-nested.json +++ b/tests/unit/v1/testdata/set-st-nested.json @@ -17,18 +17,13 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st-with-empty-map.json b/tests/unit/v1/testdata/set-st-with-empty-map.json index 063c94a0e6..a407866537 100644 --- a/tests/unit/v1/testdata/set-st-with-empty-map.json +++ b/tests/unit/v1/testdata/set-st-with-empty-map.json @@ -25,18 +25,13 @@ } } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/set-st.json b/tests/unit/v1/testdata/set-st.json index 42f2b14f1c..3e55ae111b 100644 --- a/tests/unit/v1/testdata/set-st.json +++ b/tests/unit/v1/testdata/set-st.json @@ -17,18 +17,13 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-all-transforms.json b/tests/unit/v1/testdata/update-all-transforms.json index 6f6a725df0..72b16d3a1b 100644 --- a/tests/unit/v1/testdata/update-all-transforms.json +++ b/tests/unit/v1/testdata/update-all-transforms.json @@ -25,50 +25,45 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-arrayremove-alone.json b/tests/unit/v1/testdata/update-arrayremove-alone.json index 86fc8802e5..93b8ff0528 100644 --- a/tests/unit/v1/testdata/update-arrayremove-alone.json +++ b/tests/unit/v1/testdata/update-arrayremove-alone.json @@ -10,31 +10,35 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] - }, "currentDocument": { "exists": true - } - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } ] } } diff --git a/tests/unit/v1/testdata/update-arrayremove-multi.json b/tests/unit/v1/testdata/update-arrayremove-multi.json index df880f6792..18ed0fddea 100644 --- a/tests/unit/v1/testdata/update-arrayremove-multi.json +++ b/tests/unit/v1/testdata/update-arrayremove-multi.json @@ -26,46 +26,41 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-arrayremove-nested.json b/tests/unit/v1/testdata/update-arrayremove-nested.json index 28d59aff66..7159797c77 100644 --- a/tests/unit/v1/testdata/update-arrayremove-nested.json +++ b/tests/unit/v1/testdata/update-arrayremove-nested.json @@ -26,30 +26,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-arrayremove.json b/tests/unit/v1/testdata/update-arrayremove.json index d925704db6..2311f916de 100644 --- a/tests/unit/v1/testdata/update-arrayremove.json +++ b/tests/unit/v1/testdata/update-arrayremove.json @@ -25,30 +25,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-arrayunion-alone.json b/tests/unit/v1/testdata/update-arrayunion-alone.json index 757ea48c3b..5cb08579cb 100644 --- a/tests/unit/v1/testdata/update-arrayunion-alone.json +++ b/tests/unit/v1/testdata/update-arrayunion-alone.json @@ -10,30 +10,34 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + }, + "fieldPath": "a" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-arrayunion-multi.json b/tests/unit/v1/testdata/update-arrayunion-multi.json index 3aafcd0f35..674ce2b4c2 100644 --- a/tests/unit/v1/testdata/update-arrayunion-multi.json +++ b/tests/unit/v1/testdata/update-arrayunion-multi.json @@ -26,46 +26,41 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-arrayunion-nested.json b/tests/unit/v1/testdata/update-arrayunion-nested.json index f2bf3770dc..841ceed0ac 100644 --- a/tests/unit/v1/testdata/update-arrayunion-nested.json +++ b/tests/unit/v1/testdata/update-arrayunion-nested.json @@ -26,30 +26,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-arrayunion.json b/tests/unit/v1/testdata/update-arrayunion.json index 60192c9f8c..0aca2356c1 100644 --- a/tests/unit/v1/testdata/update-arrayunion.json +++ b/tests/unit/v1/testdata/update-arrayunion.json @@ -25,30 +25,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-nested-transform-and-nested-value.json b/tests/unit/v1/testdata/update-nested-transform-and-nested-value.json index ff7bfc6ee9..2ccba0985a 100644 --- a/tests/unit/v1/testdata/update-nested-transform-and-nested-value.json +++ b/tests/unit/v1/testdata/update-nested-transform-and-nested-value.json @@ -31,18 +31,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-all-transforms.json b/tests/unit/v1/testdata/update-paths-all-transforms.json index 01a4c1143d..40adbcaf56 100644 --- a/tests/unit/v1/testdata/update-paths-all-transforms.json +++ b/tests/unit/v1/testdata/update-paths-all-transforms.json @@ -52,50 +52,45 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayremove-alone.json b/tests/unit/v1/testdata/update-paths-arrayremove-alone.json index 9bc8a14401..4097f58885 100644 --- a/tests/unit/v1/testdata/update-paths-arrayremove-alone.json +++ b/tests/unit/v1/testdata/update-paths-arrayremove-alone.json @@ -19,30 +19,34 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayremove-multi.json b/tests/unit/v1/testdata/update-paths-arrayremove-multi.json index 9a8547120e..5e76d07bac 100644 --- a/tests/unit/v1/testdata/update-paths-arrayremove-multi.json +++ b/tests/unit/v1/testdata/update-paths-arrayremove-multi.json @@ -47,46 +47,41 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayremove-nested.json b/tests/unit/v1/testdata/update-paths-arrayremove-nested.json index e7f952ec34..9ee1b2a6fe 100644 --- a/tests/unit/v1/testdata/update-paths-arrayremove-nested.json +++ b/tests/unit/v1/testdata/update-paths-arrayremove-nested.json @@ -41,30 +41,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayremove.json b/tests/unit/v1/testdata/update-paths-arrayremove.json index 673a2ca2c1..a7be888daf 100644 --- a/tests/unit/v1/testdata/update-paths-arrayremove.json +++ b/tests/unit/v1/testdata/update-paths-arrayremove.json @@ -40,30 +40,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayunion-alone.json b/tests/unit/v1/testdata/update-paths-arrayunion-alone.json index 81e1e9771a..2375d0cedb 100644 --- a/tests/unit/v1/testdata/update-paths-arrayunion-alone.json +++ b/tests/unit/v1/testdata/update-paths-arrayunion-alone.json @@ -19,30 +19,34 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + }, + "fieldPath": "a" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayunion-multi.json b/tests/unit/v1/testdata/update-paths-arrayunion-multi.json index ef421bdad1..afb6437417 100644 --- a/tests/unit/v1/testdata/update-paths-arrayunion-multi.json +++ b/tests/unit/v1/testdata/update-paths-arrayunion-multi.json @@ -47,46 +47,41 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayunion-nested.json b/tests/unit/v1/testdata/update-paths-arrayunion-nested.json index 2d73527a40..d908d02055 100644 --- a/tests/unit/v1/testdata/update-paths-arrayunion-nested.json +++ b/tests/unit/v1/testdata/update-paths-arrayunion-nested.json @@ -41,30 +41,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayunion.json b/tests/unit/v1/testdata/update-paths-arrayunion.json index 1401993d05..ed2966aede 100644 --- a/tests/unit/v1/testdata/update-paths-arrayunion.json +++ b/tests/unit/v1/testdata/update-paths-arrayunion.json @@ -40,30 +40,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-nested-transform-and-nested-value.json b/tests/unit/v1/testdata/update-paths-nested-transform-and-nested-value.json index 927d783aee..c4dead09e0 100644 --- a/tests/unit/v1/testdata/update-paths-nested-transform-and-nested-value.json +++ b/tests/unit/v1/testdata/update-paths-nested-transform-and-nested-value.json @@ -48,18 +48,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-st-alone.json b/tests/unit/v1/testdata/update-paths-st-alone.json index 085d049877..668c1c932b 100644 --- a/tests/unit/v1/testdata/update-paths-st-alone.json +++ b/tests/unit/v1/testdata/update-paths-st-alone.json @@ -19,18 +19,22 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-st-multi.json b/tests/unit/v1/testdata/update-paths-st-multi.json index 2d813801ac..8767cf3497 100644 --- a/tests/unit/v1/testdata/update-paths-st-multi.json +++ b/tests/unit/v1/testdata/update-paths-st-multi.json @@ -47,22 +47,17 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-st-nested.json b/tests/unit/v1/testdata/update-paths-st-nested.json index 8bd35c9111..94ecaccaa4 100644 --- a/tests/unit/v1/testdata/update-paths-st-nested.json +++ b/tests/unit/v1/testdata/update-paths-st-nested.json @@ -41,18 +41,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-paths-st-with-empty-map.json b/tests/unit/v1/testdata/update-paths-st-with-empty-map.json index ac60b2771d..a86ae46cd1 100644 --- a/tests/unit/v1/testdata/update-paths-st-with-empty-map.json +++ b/tests/unit/v1/testdata/update-paths-st-with-empty-map.json @@ -40,20 +40,15 @@ "a" ] }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ], "currentDocument": { "exists": true } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } } ] } diff --git a/tests/unit/v1/testdata/update-paths-st.json b/tests/unit/v1/testdata/update-paths-st.json index 011405b9bf..1710508b2d 100644 --- a/tests/unit/v1/testdata/update-paths-st.json +++ b/tests/unit/v1/testdata/update-paths-st.json @@ -40,18 +40,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-st-alone.json b/tests/unit/v1/testdata/update-st-alone.json index 1a333f30cb..49fab17691 100644 --- a/tests/unit/v1/testdata/update-st-alone.json +++ b/tests/unit/v1/testdata/update-st-alone.json @@ -10,18 +10,22 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-st-dot.json b/tests/unit/v1/testdata/update-st-dot.json index 83422ca527..8b9a769021 100644 --- a/tests/unit/v1/testdata/update-st-dot.json +++ b/tests/unit/v1/testdata/update-st-dot.json @@ -10,18 +10,22 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a.b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-st-multi.json b/tests/unit/v1/testdata/update-st-multi.json index 8105ec27f5..f474112b63 100644 --- a/tests/unit/v1/testdata/update-st-multi.json +++ b/tests/unit/v1/testdata/update-st-multi.json @@ -26,22 +26,17 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-st-nested.json b/tests/unit/v1/testdata/update-st-nested.json index 5a8e73237c..fa9f46b49f 100644 --- a/tests/unit/v1/testdata/update-st-nested.json +++ b/tests/unit/v1/testdata/update-st-nested.json @@ -26,18 +26,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-st-with-empty-map.json b/tests/unit/v1/testdata/update-st-with-empty-map.json index abeceb03ea..4a2c27dfb0 100644 --- a/tests/unit/v1/testdata/update-st-with-empty-map.json +++ b/tests/unit/v1/testdata/update-st-with-empty-map.json @@ -33,18 +33,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/tests/unit/v1/testdata/update-st.json b/tests/unit/v1/testdata/update-st.json index 6249d8bda9..71d17f3c7a 100644 --- a/tests/unit/v1/testdata/update-st.json +++ b/tests/unit/v1/testdata/update-st.json @@ -25,18 +25,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } From c4883841b0f20673741a7b2a21b1a6b58c2bd088 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 25 Sep 2020 16:19:12 -0400 Subject: [PATCH 06/10] chore: restore old conftest JSON files Partially reverts 84868a1db866f754668ac3fc7608589ec9862ce7 Rationale: get the conftest runner working using existing semantics, before updating the JSON files and making required changes (to use 'update_transforms', for instance) in a future PR. --- .../v1/testdata/create-all-transforms.json | 81 ++++++++++--------- .../v1/testdata/create-arrayremove-multi.json | 73 +++++++++-------- .../testdata/create-arrayremove-nested.json | 41 +++++----- .../unit/v1/testdata/create-arrayremove.json | 41 +++++----- .../v1/testdata/create-arrayunion-multi.json | 73 +++++++++-------- .../v1/testdata/create-arrayunion-nested.json | 41 +++++----- tests/unit/v1/testdata/create-arrayunion.json | 41 +++++----- tests/unit/v1/testdata/create-st-alone.json | 21 +++-- tests/unit/v1/testdata/create-st-multi.json | 27 ++++--- tests/unit/v1/testdata/create-st-nested.json | 19 +++-- .../v1/testdata/create-st-with-empty-map.json | 19 +++-- tests/unit/v1/testdata/create-st.json | 19 +++-- .../unit/v1/testdata/set-all-transforms.json | 81 ++++++++++--------- .../v1/testdata/set-arrayremove-multi.json | 73 +++++++++-------- .../v1/testdata/set-arrayremove-nested.json | 41 +++++----- tests/unit/v1/testdata/set-arrayremove.json | 41 +++++----- .../v1/testdata/set-arrayunion-multi.json | 73 +++++++++-------- .../v1/testdata/set-arrayunion-nested.json | 41 +++++----- tests/unit/v1/testdata/set-arrayunion.json | 41 +++++----- .../v1/testdata/set-st-alone-mergeall.json | 22 +++-- tests/unit/v1/testdata/set-st-alone.json | 19 +++-- tests/unit/v1/testdata/set-st-merge-both.json | 19 +++-- .../testdata/set-st-merge-nonleaf-alone.json | 19 +++-- .../v1/testdata/set-st-merge-nonleaf.json | 19 +++-- .../v1/testdata/set-st-merge-nowrite.json | 22 +++-- tests/unit/v1/testdata/set-st-mergeall.json | 19 +++-- tests/unit/v1/testdata/set-st-multi.json | 27 ++++--- tests/unit/v1/testdata/set-st-nested.json | 19 +++-- .../v1/testdata/set-st-with-empty-map.json | 19 +++-- tests/unit/v1/testdata/set-st.json | 19 +++-- .../v1/testdata/update-all-transforms.json | 81 ++++++++++--------- .../v1/testdata/update-arrayremove-alone.json | 50 ++++++------ .../v1/testdata/update-arrayremove-multi.json | 73 +++++++++-------- .../testdata/update-arrayremove-nested.json | 41 +++++----- .../unit/v1/testdata/update-arrayremove.json | 41 +++++----- .../v1/testdata/update-arrayunion-alone.json | 48 +++++------ .../v1/testdata/update-arrayunion-multi.json | 73 +++++++++-------- .../v1/testdata/update-arrayunion-nested.json | 41 +++++----- tests/unit/v1/testdata/update-arrayunion.json | 41 +++++----- ...ate-nested-transform-and-nested-value.json | 19 +++-- .../testdata/update-paths-all-transforms.json | 81 ++++++++++--------- .../update-paths-arrayremove-alone.json | 48 +++++------ .../update-paths-arrayremove-multi.json | 73 +++++++++-------- .../update-paths-arrayremove-nested.json | 41 +++++----- .../v1/testdata/update-paths-arrayremove.json | 41 +++++----- .../update-paths-arrayunion-alone.json | 48 +++++------ .../update-paths-arrayunion-multi.json | 73 +++++++++-------- .../update-paths-arrayunion-nested.json | 41 +++++----- .../v1/testdata/update-paths-arrayunion.json | 41 +++++----- ...ths-nested-transform-and-nested-value.json | 19 +++-- .../v1/testdata/update-paths-st-alone.json | 24 +++--- .../v1/testdata/update-paths-st-multi.json | 27 ++++--- .../v1/testdata/update-paths-st-nested.json | 19 +++-- .../update-paths-st-with-empty-map.json | 17 ++-- tests/unit/v1/testdata/update-paths-st.json | 19 +++-- tests/unit/v1/testdata/update-st-alone.json | 24 +++--- tests/unit/v1/testdata/update-st-dot.json | 24 +++--- tests/unit/v1/testdata/update-st-multi.json | 27 ++++--- tests/unit/v1/testdata/update-st-nested.json | 19 +++-- .../v1/testdata/update-st-with-empty-map.json | 19 +++-- tests/unit/v1/testdata/update-st.json | 19 +++-- 61 files changed, 1290 insertions(+), 1072 deletions(-) diff --git a/tests/unit/v1/testdata/create-all-transforms.json b/tests/unit/v1/testdata/create-all-transforms.json index 6389599987..82831624bb 100644 --- a/tests/unit/v1/testdata/create-all-transforms.json +++ b/tests/unit/v1/testdata/create-all-transforms.json @@ -20,45 +20,50 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-arrayremove-multi.json b/tests/unit/v1/testdata/create-arrayremove-multi.json index 331a53bf9c..548a983808 100644 --- a/tests/unit/v1/testdata/create-arrayremove-multi.json +++ b/tests/unit/v1/testdata/create-arrayremove-multi.json @@ -20,41 +20,46 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-arrayremove-nested.json b/tests/unit/v1/testdata/create-arrayremove-nested.json index 00c73d05cc..fa01bd7e00 100644 --- a/tests/unit/v1/testdata/create-arrayremove-nested.json +++ b/tests/unit/v1/testdata/create-arrayremove-nested.json @@ -20,25 +20,30 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-arrayremove.json b/tests/unit/v1/testdata/create-arrayremove.json index 646e259f6f..a69be14b7b 100644 --- a/tests/unit/v1/testdata/create-arrayremove.json +++ b/tests/unit/v1/testdata/create-arrayremove.json @@ -20,25 +20,30 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-arrayunion-multi.json b/tests/unit/v1/testdata/create-arrayunion-multi.json index 5ba324f429..7ca9852f48 100644 --- a/tests/unit/v1/testdata/create-arrayunion-multi.json +++ b/tests/unit/v1/testdata/create-arrayunion-multi.json @@ -20,41 +20,46 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-arrayunion-nested.json b/tests/unit/v1/testdata/create-arrayunion-nested.json index 2a21509004..a2f20299d3 100644 --- a/tests/unit/v1/testdata/create-arrayunion-nested.json +++ b/tests/unit/v1/testdata/create-arrayunion-nested.json @@ -20,25 +20,30 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-arrayunion.json b/tests/unit/v1/testdata/create-arrayunion.json index 99a75feded..26d0799466 100644 --- a/tests/unit/v1/testdata/create-arrayunion.json +++ b/tests/unit/v1/testdata/create-arrayunion.json @@ -20,25 +20,30 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-st-alone.json b/tests/unit/v1/testdata/create-st-alone.json index 177293906b..20c5e8ec32 100644 --- a/tests/unit/v1/testdata/create-st-alone.json +++ b/tests/unit/v1/testdata/create-st-alone.json @@ -10,19 +10,18 @@ "database": "projects/projectID/databases/(default)", "writes": [ { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + }, "currentDocument": { "exists": false - }, - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] + } } ] } diff --git a/tests/unit/v1/testdata/create-st-multi.json b/tests/unit/v1/testdata/create-st-multi.json index 41f3cd811c..89430e2b64 100644 --- a/tests/unit/v1/testdata/create-st-multi.json +++ b/tests/unit/v1/testdata/create-st-multi.json @@ -20,17 +20,22 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-st-nested.json b/tests/unit/v1/testdata/create-st-nested.json index 7316d916f4..f2a3a8d1f6 100644 --- a/tests/unit/v1/testdata/create-st-nested.json +++ b/tests/unit/v1/testdata/create-st-nested.json @@ -20,13 +20,18 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-st-with-empty-map.json b/tests/unit/v1/testdata/create-st-with-empty-map.json index b638a0c9db..730afd154f 100644 --- a/tests/unit/v1/testdata/create-st-with-empty-map.json +++ b/tests/unit/v1/testdata/create-st-with-empty-map.json @@ -28,13 +28,18 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/create-st.json b/tests/unit/v1/testdata/create-st.json index c4ad4be46b..705f76ed16 100644 --- a/tests/unit/v1/testdata/create-st.json +++ b/tests/unit/v1/testdata/create-st.json @@ -20,13 +20,18 @@ }, "currentDocument": { "exists": false - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-all-transforms.json b/tests/unit/v1/testdata/set-all-transforms.json index a26b51b007..5c8b1373d4 100644 --- a/tests/unit/v1/testdata/set-all-transforms.json +++ b/tests/unit/v1/testdata/set-all-transforms.json @@ -17,45 +17,50 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-arrayremove-multi.json b/tests/unit/v1/testdata/set-arrayremove-multi.json index dc2ace22f8..3ea9b0dbd8 100644 --- a/tests/unit/v1/testdata/set-arrayremove-multi.json +++ b/tests/unit/v1/testdata/set-arrayremove-multi.json @@ -17,41 +17,46 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-arrayremove-nested.json b/tests/unit/v1/testdata/set-arrayremove-nested.json index 1e25b8f26b..4db133f2c5 100644 --- a/tests/unit/v1/testdata/set-arrayremove-nested.json +++ b/tests/unit/v1/testdata/set-arrayremove-nested.json @@ -17,25 +17,30 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-arrayremove.json b/tests/unit/v1/testdata/set-arrayremove.json index e0506b22be..18969ef80a 100644 --- a/tests/unit/v1/testdata/set-arrayremove.json +++ b/tests/unit/v1/testdata/set-arrayremove.json @@ -17,25 +17,30 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-arrayunion-multi.json b/tests/unit/v1/testdata/set-arrayunion-multi.json index 502d7dc7df..3d076397c5 100644 --- a/tests/unit/v1/testdata/set-arrayunion-multi.json +++ b/tests/unit/v1/testdata/set-arrayunion-multi.json @@ -17,41 +17,46 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-arrayunion-nested.json b/tests/unit/v1/testdata/set-arrayunion-nested.json index 7084e6bcd9..e265f6c613 100644 --- a/tests/unit/v1/testdata/set-arrayunion-nested.json +++ b/tests/unit/v1/testdata/set-arrayunion-nested.json @@ -17,25 +17,30 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-arrayunion.json b/tests/unit/v1/testdata/set-arrayunion.json index af12b33dd0..856e075173 100644 --- a/tests/unit/v1/testdata/set-arrayunion.json +++ b/tests/unit/v1/testdata/set-arrayunion.json @@ -17,25 +17,30 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-alone-mergeall.json b/tests/unit/v1/testdata/set-st-alone-mergeall.json index f6b60af810..d95bf0973b 100644 --- a/tests/unit/v1/testdata/set-st-alone-mergeall.json +++ b/tests/unit/v1/testdata/set-st-alone-mergeall.json @@ -13,19 +13,15 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateMask": { - "fieldPaths": [] - }, - "updateTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-alone.json b/tests/unit/v1/testdata/set-st-alone.json index 1d28fd6f18..3fe931394b 100644 --- a/tests/unit/v1/testdata/set-st-alone.json +++ b/tests/unit/v1/testdata/set-st-alone.json @@ -13,13 +13,18 @@ "update": { "name": "projects/projectID/databases/(default)/documents/C/d", "fields": {} - }, - "updateTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-merge-both.json b/tests/unit/v1/testdata/set-st-merge-both.json index 359c899a1e..a39ada55f7 100644 --- a/tests/unit/v1/testdata/set-st-merge-both.json +++ b/tests/unit/v1/testdata/set-st-merge-both.json @@ -36,13 +36,18 @@ "fieldPaths": [ "a" ] - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-merge-nonleaf-alone.json b/tests/unit/v1/testdata/set-st-merge-nonleaf-alone.json index 5af99ab0a5..4193b00ea6 100644 --- a/tests/unit/v1/testdata/set-st-merge-nonleaf-alone.json +++ b/tests/unit/v1/testdata/set-st-merge-nonleaf-alone.json @@ -26,13 +26,18 @@ "fieldPaths": [ "h" ] - }, - "updateTransforms": [ - { - "fieldPath": "h.g", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "h.g", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-merge-nonleaf.json b/tests/unit/v1/testdata/set-st-merge-nonleaf.json index e66ca87bf8..5e91d663b8 100644 --- a/tests/unit/v1/testdata/set-st-merge-nonleaf.json +++ b/tests/unit/v1/testdata/set-st-merge-nonleaf.json @@ -37,13 +37,18 @@ "fieldPaths": [ "h" ] - }, - "updateTransforms": [ - { - "fieldPath": "h.g", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "h.g", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-merge-nowrite.json b/tests/unit/v1/testdata/set-st-merge-nowrite.json index 44091b1276..08fa8b52f5 100644 --- a/tests/unit/v1/testdata/set-st-merge-nowrite.json +++ b/tests/unit/v1/testdata/set-st-merge-nowrite.json @@ -19,19 +19,15 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateMask": { - "fieldPaths": [] - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-mergeall.json b/tests/unit/v1/testdata/set-st-mergeall.json index f913d69e61..26883c0382 100644 --- a/tests/unit/v1/testdata/set-st-mergeall.json +++ b/tests/unit/v1/testdata/set-st-mergeall.json @@ -25,13 +25,18 @@ "fieldPaths": [ "a" ] - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-multi.json b/tests/unit/v1/testdata/set-st-multi.json index 03200729ca..23c06f4976 100644 --- a/tests/unit/v1/testdata/set-st-multi.json +++ b/tests/unit/v1/testdata/set-st-multi.json @@ -17,17 +17,22 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-nested.json b/tests/unit/v1/testdata/set-st-nested.json index 58406e80b3..5c94c33f94 100644 --- a/tests/unit/v1/testdata/set-st-nested.json +++ b/tests/unit/v1/testdata/set-st-nested.json @@ -17,13 +17,18 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st-with-empty-map.json b/tests/unit/v1/testdata/set-st-with-empty-map.json index a407866537..063c94a0e6 100644 --- a/tests/unit/v1/testdata/set-st-with-empty-map.json +++ b/tests/unit/v1/testdata/set-st-with-empty-map.json @@ -25,13 +25,18 @@ } } } - }, - "updateTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/set-st.json b/tests/unit/v1/testdata/set-st.json index 3e55ae111b..42f2b14f1c 100644 --- a/tests/unit/v1/testdata/set-st.json +++ b/tests/unit/v1/testdata/set-st.json @@ -17,13 +17,18 @@ "integerValue": "1" } } - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-all-transforms.json b/tests/unit/v1/testdata/update-all-transforms.json index 72b16d3a1b..6f6a725df0 100644 --- a/tests/unit/v1/testdata/update-all-transforms.json +++ b/tests/unit/v1/testdata/update-all-transforms.json @@ -25,45 +25,50 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-arrayremove-alone.json b/tests/unit/v1/testdata/update-arrayremove-alone.json index 93b8ff0528..86fc8802e5 100644 --- a/tests/unit/v1/testdata/update-arrayremove-alone.json +++ b/tests/unit/v1/testdata/update-arrayremove-alone.json @@ -10,35 +10,31 @@ "database": "projects/projectID/databases/(default)", "writes": [ { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + }, "currentDocument": { "exists": true - }, - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateMask": { - "fieldPaths": [] - }, - "updateTransforms": [ - { - "fieldPath": "a", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] - } + } + } ] } } diff --git a/tests/unit/v1/testdata/update-arrayremove-multi.json b/tests/unit/v1/testdata/update-arrayremove-multi.json index 18ed0fddea..df880f6792 100644 --- a/tests/unit/v1/testdata/update-arrayremove-multi.json +++ b/tests/unit/v1/testdata/update-arrayremove-multi.json @@ -26,41 +26,46 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-arrayremove-nested.json b/tests/unit/v1/testdata/update-arrayremove-nested.json index 7159797c77..28d59aff66 100644 --- a/tests/unit/v1/testdata/update-arrayremove-nested.json +++ b/tests/unit/v1/testdata/update-arrayremove-nested.json @@ -26,25 +26,30 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-arrayremove.json b/tests/unit/v1/testdata/update-arrayremove.json index 2311f916de..d925704db6 100644 --- a/tests/unit/v1/testdata/update-arrayremove.json +++ b/tests/unit/v1/testdata/update-arrayremove.json @@ -25,25 +25,30 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-arrayunion-alone.json b/tests/unit/v1/testdata/update-arrayunion-alone.json index 5cb08579cb..757ea48c3b 100644 --- a/tests/unit/v1/testdata/update-arrayunion-alone.json +++ b/tests/unit/v1/testdata/update-arrayunion-alone.json @@ -10,34 +10,30 @@ "database": "projects/projectID/databases/(default)", "writes": [ { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + }, "currentDocument": { "exists": true - }, - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateMask": { - "fieldPaths": [] - }, - "updateTransforms": [ - { - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - }, - "fieldPath": "a" - } - ] + } } ] } diff --git a/tests/unit/v1/testdata/update-arrayunion-multi.json b/tests/unit/v1/testdata/update-arrayunion-multi.json index 674ce2b4c2..3aafcd0f35 100644 --- a/tests/unit/v1/testdata/update-arrayunion-multi.json +++ b/tests/unit/v1/testdata/update-arrayunion-multi.json @@ -26,41 +26,46 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-arrayunion-nested.json b/tests/unit/v1/testdata/update-arrayunion-nested.json index 841ceed0ac..f2bf3770dc 100644 --- a/tests/unit/v1/testdata/update-arrayunion-nested.json +++ b/tests/unit/v1/testdata/update-arrayunion-nested.json @@ -26,25 +26,30 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-arrayunion.json b/tests/unit/v1/testdata/update-arrayunion.json index 0aca2356c1..60192c9f8c 100644 --- a/tests/unit/v1/testdata/update-arrayunion.json +++ b/tests/unit/v1/testdata/update-arrayunion.json @@ -25,25 +25,30 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-nested-transform-and-nested-value.json b/tests/unit/v1/testdata/update-nested-transform-and-nested-value.json index 2ccba0985a..ff7bfc6ee9 100644 --- a/tests/unit/v1/testdata/update-nested-transform-and-nested-value.json +++ b/tests/unit/v1/testdata/update-nested-transform-and-nested-value.json @@ -31,13 +31,18 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-all-transforms.json b/tests/unit/v1/testdata/update-paths-all-transforms.json index 40adbcaf56..01a4c1143d 100644 --- a/tests/unit/v1/testdata/update-paths-all-transforms.json +++ b/tests/unit/v1/testdata/update-paths-all-transforms.json @@ -52,45 +52,50 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayremove-alone.json b/tests/unit/v1/testdata/update-paths-arrayremove-alone.json index 4097f58885..9bc8a14401 100644 --- a/tests/unit/v1/testdata/update-paths-arrayremove-alone.json +++ b/tests/unit/v1/testdata/update-paths-arrayremove-alone.json @@ -19,34 +19,30 @@ "database": "projects/projectID/databases/(default)", "writes": [ { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + }, "currentDocument": { "exists": true - }, - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateMask": { - "fieldPaths": [] - }, - "updateTransforms": [ - { - "fieldPath": "a", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayremove-multi.json b/tests/unit/v1/testdata/update-paths-arrayremove-multi.json index 5e76d07bac..9a8547120e 100644 --- a/tests/unit/v1/testdata/update-paths-arrayremove-multi.json +++ b/tests/unit/v1/testdata/update-paths-arrayremove-multi.json @@ -47,41 +47,46 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayremove-nested.json b/tests/unit/v1/testdata/update-paths-arrayremove-nested.json index 9ee1b2a6fe..e7f952ec34 100644 --- a/tests/unit/v1/testdata/update-paths-arrayremove-nested.json +++ b/tests/unit/v1/testdata/update-paths-arrayremove-nested.json @@ -41,25 +41,30 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayremove.json b/tests/unit/v1/testdata/update-paths-arrayremove.json index a7be888daf..673a2ca2c1 100644 --- a/tests/unit/v1/testdata/update-paths-arrayremove.json +++ b/tests/unit/v1/testdata/update-paths-arrayremove.json @@ -40,25 +40,30 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayunion-alone.json b/tests/unit/v1/testdata/update-paths-arrayunion-alone.json index 2375d0cedb..81e1e9771a 100644 --- a/tests/unit/v1/testdata/update-paths-arrayunion-alone.json +++ b/tests/unit/v1/testdata/update-paths-arrayunion-alone.json @@ -19,34 +19,30 @@ "database": "projects/projectID/databases/(default)", "writes": [ { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + }, "currentDocument": { "exists": true - }, - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateMask": { - "fieldPaths": [] - }, - "updateTransforms": [ - { - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - }, - "fieldPath": "a" - } - ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayunion-multi.json b/tests/unit/v1/testdata/update-paths-arrayunion-multi.json index afb6437417..ef421bdad1 100644 --- a/tests/unit/v1/testdata/update-paths-arrayunion-multi.json +++ b/tests/unit/v1/testdata/update-paths-arrayunion-multi.json @@ -47,41 +47,46 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayunion-nested.json b/tests/unit/v1/testdata/update-paths-arrayunion-nested.json index d908d02055..2d73527a40 100644 --- a/tests/unit/v1/testdata/update-paths-arrayunion-nested.json +++ b/tests/unit/v1/testdata/update-paths-arrayunion-nested.json @@ -41,25 +41,30 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-arrayunion.json b/tests/unit/v1/testdata/update-paths-arrayunion.json index ed2966aede..1401993d05 100644 --- a/tests/unit/v1/testdata/update-paths-arrayunion.json +++ b/tests/unit/v1/testdata/update-paths-arrayunion.json @@ -40,25 +40,30 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } } - } - ] + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-nested-transform-and-nested-value.json b/tests/unit/v1/testdata/update-paths-nested-transform-and-nested-value.json index c4dead09e0..927d783aee 100644 --- a/tests/unit/v1/testdata/update-paths-nested-transform-and-nested-value.json +++ b/tests/unit/v1/testdata/update-paths-nested-transform-and-nested-value.json @@ -48,13 +48,18 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-st-alone.json b/tests/unit/v1/testdata/update-paths-st-alone.json index 668c1c932b..085d049877 100644 --- a/tests/unit/v1/testdata/update-paths-st-alone.json +++ b/tests/unit/v1/testdata/update-paths-st-alone.json @@ -19,22 +19,18 @@ "database": "projects/projectID/databases/(default)", "writes": [ { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + }, "currentDocument": { "exists": true - }, - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateMask": { - "fieldPaths": [] - }, - "updateTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-st-multi.json b/tests/unit/v1/testdata/update-paths-st-multi.json index 8767cf3497..2d813801ac 100644 --- a/tests/unit/v1/testdata/update-paths-st-multi.json +++ b/tests/unit/v1/testdata/update-paths-st-multi.json @@ -47,17 +47,22 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-st-nested.json b/tests/unit/v1/testdata/update-paths-st-nested.json index 94ecaccaa4..8bd35c9111 100644 --- a/tests/unit/v1/testdata/update-paths-st-nested.json +++ b/tests/unit/v1/testdata/update-paths-st-nested.json @@ -41,13 +41,18 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-st-with-empty-map.json b/tests/unit/v1/testdata/update-paths-st-with-empty-map.json index a86ae46cd1..ac60b2771d 100644 --- a/tests/unit/v1/testdata/update-paths-st-with-empty-map.json +++ b/tests/unit/v1/testdata/update-paths-st-with-empty-map.json @@ -40,15 +40,20 @@ "a" ] }, - "updateTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ], "currentDocument": { "exists": true } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-paths-st.json b/tests/unit/v1/testdata/update-paths-st.json index 1710508b2d..011405b9bf 100644 --- a/tests/unit/v1/testdata/update-paths-st.json +++ b/tests/unit/v1/testdata/update-paths-st.json @@ -40,13 +40,18 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-st-alone.json b/tests/unit/v1/testdata/update-st-alone.json index 49fab17691..1a333f30cb 100644 --- a/tests/unit/v1/testdata/update-st-alone.json +++ b/tests/unit/v1/testdata/update-st-alone.json @@ -10,22 +10,18 @@ "database": "projects/projectID/databases/(default)", "writes": [ { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + }, "currentDocument": { "exists": true - }, - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateMask": { - "fieldPaths": [] - }, - "updateTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] + } } ] } diff --git a/tests/unit/v1/testdata/update-st-dot.json b/tests/unit/v1/testdata/update-st-dot.json index 8b9a769021..83422ca527 100644 --- a/tests/unit/v1/testdata/update-st-dot.json +++ b/tests/unit/v1/testdata/update-st-dot.json @@ -10,22 +10,18 @@ "database": "projects/projectID/databases/(default)", "writes": [ { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + }, "currentDocument": { "exists": true - }, - "update": { - "fields": {}, - "name": "projects/projectID/databases/(default)/documents/C/d" - }, - "updateMask": { - "fieldPaths": [] - }, - "updateTransforms": [ - { - "fieldPath": "a.b.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } } ] } diff --git a/tests/unit/v1/testdata/update-st-multi.json b/tests/unit/v1/testdata/update-st-multi.json index f474112b63..8105ec27f5 100644 --- a/tests/unit/v1/testdata/update-st-multi.json +++ b/tests/unit/v1/testdata/update-st-multi.json @@ -26,17 +26,22 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-st-nested.json b/tests/unit/v1/testdata/update-st-nested.json index fa9f46b49f..5a8e73237c 100644 --- a/tests/unit/v1/testdata/update-st-nested.json +++ b/tests/unit/v1/testdata/update-st-nested.json @@ -26,13 +26,18 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-st-with-empty-map.json b/tests/unit/v1/testdata/update-st-with-empty-map.json index 4a2c27dfb0..abeceb03ea 100644 --- a/tests/unit/v1/testdata/update-st-with-empty-map.json +++ b/tests/unit/v1/testdata/update-st-with-empty-map.json @@ -33,13 +33,18 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } diff --git a/tests/unit/v1/testdata/update-st.json b/tests/unit/v1/testdata/update-st.json index 71d17f3c7a..6249d8bda9 100644 --- a/tests/unit/v1/testdata/update-st.json +++ b/tests/unit/v1/testdata/update-st.json @@ -25,13 +25,18 @@ }, "currentDocument": { "exists": true - }, - "updateTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } } ] } From 55a2e04755b6eda719e58d9e29015d12d75b6393 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 25 Sep 2020 16:22:50 -0400 Subject: [PATCH 07/10] chore: blacken --- google/cloud/firestore_v1/types/tests.py | 211 ++++++++--------------- tests/unit/v1/test_cross_language.py | 36 +--- 2 files changed, 78 insertions(+), 169 deletions(-) diff --git a/google/cloud/firestore_v1/types/tests.py b/google/cloud/firestore_v1/types/tests.py index 933aa93704..cfccb5beee 100644 --- a/google/cloud/firestore_v1/types/tests.py +++ b/google/cloud/firestore_v1/types/tests.py @@ -26,28 +26,28 @@ __protobuf__ = proto.module( - package='google.cloud.firestore_v1', + package="google.cloud.firestore_v1", manifest={ - 'TestFile', - 'Test', - 'GetTest', - 'CreateTest', - 'SetTest', - 'UpdateTest', - 'UpdatePathsTest', - 'DeleteTest', - 'SetOption', - 'QueryTest', - 'Clause', - 'Select', - 'Where', - 'OrderBy', - 'Cursor_', - 'DocSnapshot', - 'FieldPath', - 'ListenTest', - 'Snapshot', - 'DocChange', + "TestFile", + "Test", + "GetTest", + "CreateTest", + "SetTest", + "UpdateTest", + "UpdatePathsTest", + "DeleteTest", + "SetOption", + "QueryTest", + "Clause", + "Select", + "Where", + "OrderBy", + "Cursor_", + "DocSnapshot", + "FieldPath", + "ListenTest", + "Snapshot", + "DocChange", }, ) @@ -60,9 +60,7 @@ class TestFile(proto.Message): """ - tests = proto.RepeatedField(proto.MESSAGE, number=1, - message='Test', - ) + tests = proto.RepeatedField(proto.MESSAGE, number=1, message="Test",) class Test(proto.Message): @@ -97,37 +95,23 @@ class Test(proto.Message): comment = proto.Field(proto.STRING, number=10) - get = proto.Field(proto.MESSAGE, number=2, oneof='test', - message='GetTest', - ) + get = proto.Field(proto.MESSAGE, number=2, oneof="test", message="GetTest",) - create = proto.Field(proto.MESSAGE, number=3, oneof='test', - message='CreateTest', - ) + create = proto.Field(proto.MESSAGE, number=3, oneof="test", message="CreateTest",) - set_ = proto.Field(proto.MESSAGE, number=4, oneof='test', - message='SetTest', - ) + set_ = proto.Field(proto.MESSAGE, number=4, oneof="test", message="SetTest",) - update = proto.Field(proto.MESSAGE, number=5, oneof='test', - message='UpdateTest', - ) + update = proto.Field(proto.MESSAGE, number=5, oneof="test", message="UpdateTest",) - update_paths = proto.Field(proto.MESSAGE, number=6, oneof='test', - message='UpdatePathsTest', + update_paths = proto.Field( + proto.MESSAGE, number=6, oneof="test", message="UpdatePathsTest", ) - delete = proto.Field(proto.MESSAGE, number=7, oneof='test', - message='DeleteTest', - ) + delete = proto.Field(proto.MESSAGE, number=7, oneof="test", message="DeleteTest",) - query = proto.Field(proto.MESSAGE, number=8, oneof='test', - message='QueryTest', - ) + query = proto.Field(proto.MESSAGE, number=8, oneof="test", message="QueryTest",) - listen = proto.Field(proto.MESSAGE, number=9, oneof='test', - message='ListenTest', - ) + listen = proto.Field(proto.MESSAGE, number=9, oneof="test", message="ListenTest",) class GetTest(proto.Message): @@ -144,8 +128,8 @@ class GetTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) - request = proto.Field(proto.MESSAGE, number=2, - message=firestore.GetDocumentRequest, + request = proto.Field( + proto.MESSAGE, number=2, message=firestore.GetDocumentRequest, ) @@ -174,9 +158,7 @@ class CreateTest(proto.Message): json_data = proto.Field(proto.STRING, number=2) - request = proto.Field(proto.MESSAGE, number=3, - message=firestore.CommitRequest, - ) + request = proto.Field(proto.MESSAGE, number=3, message=firestore.CommitRequest,) is_error = proto.Field(proto.BOOL, number=4) @@ -199,15 +181,11 @@ class SetTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) - option = proto.Field(proto.MESSAGE, number=2, - message='SetOption', - ) + option = proto.Field(proto.MESSAGE, number=2, message="SetOption",) json_data = proto.Field(proto.STRING, number=3) - request = proto.Field(proto.MESSAGE, number=4, - message=firestore.CommitRequest, - ) + request = proto.Field(proto.MESSAGE, number=4, message=firestore.CommitRequest,) is_error = proto.Field(proto.BOOL, number=5) @@ -231,15 +209,11 @@ class UpdateTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) - precondition = proto.Field(proto.MESSAGE, number=2, - message=common.Precondition, - ) + precondition = proto.Field(proto.MESSAGE, number=2, message=common.Precondition,) json_data = proto.Field(proto.STRING, number=3) - request = proto.Field(proto.MESSAGE, number=4, - message=firestore.CommitRequest, - ) + request = proto.Field(proto.MESSAGE, number=4, message=firestore.CommitRequest,) is_error = proto.Field(proto.BOOL, number=5) @@ -266,19 +240,13 @@ class UpdatePathsTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) - precondition = proto.Field(proto.MESSAGE, number=2, - message=common.Precondition, - ) + precondition = proto.Field(proto.MESSAGE, number=2, message=common.Precondition,) - field_paths = proto.RepeatedField(proto.MESSAGE, number=3, - message='FieldPath', - ) + field_paths = proto.RepeatedField(proto.MESSAGE, number=3, message="FieldPath",) json_values = proto.RepeatedField(proto.STRING, number=4) - request = proto.Field(proto.MESSAGE, number=5, - message=firestore.CommitRequest, - ) + request = proto.Field(proto.MESSAGE, number=5, message=firestore.CommitRequest,) is_error = proto.Field(proto.BOOL, number=6) @@ -299,13 +267,9 @@ class DeleteTest(proto.Message): doc_ref_path = proto.Field(proto.STRING, number=1) - precondition = proto.Field(proto.MESSAGE, number=2, - message=common.Precondition, - ) + precondition = proto.Field(proto.MESSAGE, number=2, message=common.Precondition,) - request = proto.Field(proto.MESSAGE, number=3, - message=firestore.CommitRequest, - ) + request = proto.Field(proto.MESSAGE, number=3, message=firestore.CommitRequest,) is_error = proto.Field(proto.BOOL, number=4) @@ -323,9 +287,7 @@ class SetOption(proto.Message): all_ = proto.Field(proto.BOOL, number=1) - fields = proto.RepeatedField(proto.MESSAGE, number=2, - message='FieldPath', - ) + fields = proto.RepeatedField(proto.MESSAGE, number=2, message="FieldPath",) class QueryTest(proto.Message): @@ -345,13 +307,9 @@ class QueryTest(proto.Message): coll_path = proto.Field(proto.STRING, number=1) - clauses = proto.RepeatedField(proto.MESSAGE, number=2, - message='Clause', - ) + clauses = proto.RepeatedField(proto.MESSAGE, number=2, message="Clause",) - query = proto.Field(proto.MESSAGE, number=3, - message=gcf_query.StructuredQuery, - ) + query = proto.Field(proto.MESSAGE, number=3, message=gcf_query.StructuredQuery,) is_error = proto.Field(proto.BOOL, number=4) @@ -380,36 +338,26 @@ class Clause(proto.Message): """ - select = proto.Field(proto.MESSAGE, number=1, oneof='clause', - message='Select', - ) + select = proto.Field(proto.MESSAGE, number=1, oneof="clause", message="Select",) - where = proto.Field(proto.MESSAGE, number=2, oneof='clause', - message='Where', - ) + where = proto.Field(proto.MESSAGE, number=2, oneof="clause", message="Where",) - order_by = proto.Field(proto.MESSAGE, number=3, oneof='clause', - message='OrderBy', - ) + order_by = proto.Field(proto.MESSAGE, number=3, oneof="clause", message="OrderBy",) - offset = proto.Field(proto.INT32, number=4, oneof='clause') + offset = proto.Field(proto.INT32, number=4, oneof="clause") - limit = proto.Field(proto.INT32, number=5, oneof='clause') + limit = proto.Field(proto.INT32, number=5, oneof="clause") - start_at = proto.Field(proto.MESSAGE, number=6, oneof='clause', - message='Cursor_', - ) + start_at = proto.Field(proto.MESSAGE, number=6, oneof="clause", message="Cursor_",) - start_after = proto.Field(proto.MESSAGE, number=7, oneof='clause', - message='Cursor_', + start_after = proto.Field( + proto.MESSAGE, number=7, oneof="clause", message="Cursor_", ) - end_at = proto.Field(proto.MESSAGE, number=8, oneof='clause', - message='Cursor_', - ) + end_at = proto.Field(proto.MESSAGE, number=8, oneof="clause", message="Cursor_",) - end_before = proto.Field(proto.MESSAGE, number=9, oneof='clause', - message='Cursor_', + end_before = proto.Field( + proto.MESSAGE, number=9, oneof="clause", message="Cursor_", ) @@ -421,9 +369,7 @@ class Select(proto.Message): """ - fields = proto.RepeatedField(proto.MESSAGE, number=1, - message='FieldPath', - ) + fields = proto.RepeatedField(proto.MESSAGE, number=1, message="FieldPath",) class Where(proto.Message): @@ -438,9 +384,7 @@ class Where(proto.Message): """ - path = proto.Field(proto.MESSAGE, number=1, - message='FieldPath', - ) + path = proto.Field(proto.MESSAGE, number=1, message="FieldPath",) op = proto.Field(proto.STRING, number=2) @@ -457,9 +401,7 @@ class OrderBy(proto.Message): "asc" or "desc". """ - path = proto.Field(proto.MESSAGE, number=1, - message='FieldPath', - ) + path = proto.Field(proto.MESSAGE, number=1, message="FieldPath",) direction = proto.Field(proto.STRING, number=2) @@ -474,9 +416,7 @@ class Cursor_(proto.Message): """ - doc_snapshot = proto.Field(proto.MESSAGE, number=1, - message='DocSnapshot', - ) + doc_snapshot = proto.Field(proto.MESSAGE, number=1, message="DocSnapshot",) json_values = proto.RepeatedField(proto.STRING, number=2) @@ -530,13 +470,11 @@ class ListenTest(proto.Message): """ - responses = proto.RepeatedField(proto.MESSAGE, number=1, - message=firestore.ListenResponse, + responses = proto.RepeatedField( + proto.MESSAGE, number=1, message=firestore.ListenResponse, ) - snapshots = proto.RepeatedField(proto.MESSAGE, number=2, - message='Snapshot', - ) + snapshots = proto.RepeatedField(proto.MESSAGE, number=2, message="Snapshot",) is_error = proto.Field(proto.BOOL, number=3) @@ -553,17 +491,11 @@ class Snapshot(proto.Message): """ - docs = proto.RepeatedField(proto.MESSAGE, number=1, - message=document.Document, - ) + docs = proto.RepeatedField(proto.MESSAGE, number=1, message=document.Document,) - changes = proto.RepeatedField(proto.MESSAGE, number=2, - message='DocChange', - ) + changes = proto.RepeatedField(proto.MESSAGE, number=2, message="DocChange",) - read_time = proto.Field(proto.MESSAGE, number=3, - message=timestamp.Timestamp, - ) + read_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) class DocChange(proto.Message): @@ -579,6 +511,7 @@ class DocChange(proto.Message): new_index (int): """ + class Kind(proto.Enum): r"""""" KIND_UNSPECIFIED = 0 @@ -586,13 +519,9 @@ class Kind(proto.Enum): REMOVED = 2 MODIFIED = 3 - kind = proto.Field(proto.ENUM, number=1, - enum=Kind, - ) + kind = proto.Field(proto.ENUM, number=1, enum=Kind,) - doc = proto.Field(proto.MESSAGE, number=2, - message=document.Document, - ) + doc = proto.Field(proto.MESSAGE, number=2, message=document.Document,) old_index = proto.Field(proto.INT32, number=3) diff --git a/tests/unit/v1/test_cross_language.py b/tests/unit/v1/test_cross_language.py index 0956917fce..cf3ffbbd48 100644 --- a/tests/unit/v1/test_cross_language.py +++ b/tests/unit/v1/test_cross_language.py @@ -50,51 +50,31 @@ def _load_test_json(filename): ALL_TESTPROTOS.extend(_load_test_json(filename)) _CREATE_TESTPROTOS = [ - test_proto - for test_proto in ALL_TESTPROTOS - if "create" in test_proto + test_proto for test_proto in ALL_TESTPROTOS if "create" in test_proto ] -_GET_TESTPROTOS = [ - test_proto - for test_proto in ALL_TESTPROTOS - if "get" in test_proto -] +_GET_TESTPROTOS = [test_proto for test_proto in ALL_TESTPROTOS if "get" in test_proto] -_SET_TESTPROTOS = [ - test_proto - for test_proto in ALL_TESTPROTOS - if "set_" in test_proto -] +_SET_TESTPROTOS = [test_proto for test_proto in ALL_TESTPROTOS if "set_" in test_proto] _UPDATE_TESTPROTOS = [ - test_proto - for test_proto in ALL_TESTPROTOS - if "update" in test_proto + test_proto for test_proto in ALL_TESTPROTOS if "update" in test_proto ] _UPDATE_PATHS_TESTPROTOS = [ - test_proto - for test_proto in ALL_TESTPROTOS - if "update_paths" in test_proto + test_proto for test_proto in ALL_TESTPROTOS if "update_paths" in test_proto ] _DELETE_TESTPROTOS = [ - test_proto - for test_proto in ALL_TESTPROTOS - if "delete" in test_proto + test_proto for test_proto in ALL_TESTPROTOS if "delete" in test_proto ] _LISTEN_TESTPROTOS = [ - test_proto - for test_proto in ALL_TESTPROTOS - if "listen" in test_proto + test_proto for test_proto in ALL_TESTPROTOS if "listen" in test_proto ] _QUERY_TESTPROTOS = [ - test_proto - for test_proto in ALL_TESTPROTOS - if "query" in test_proto + test_proto for test_proto in ALL_TESTPROTOS if "query" in test_proto ] From 15e01081c3fd1a6f0a4744a85127c6bc95913b47 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 25 Sep 2020 16:29:52 -0400 Subject: [PATCH 08/10] tests: get cross-language conftests working on 'master' Closes #95. --- tests/unit/v1/test_cross_language.py | 42 ++++++++++++++++++---------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/tests/unit/v1/test_cross_language.py b/tests/unit/v1/test_cross_language.py index cf3ffbbd48..67c8c952f6 100644 --- a/tests/unit/v1/test_cross_language.py +++ b/tests/unit/v1/test_cross_language.py @@ -22,7 +22,6 @@ import mock import pytest -from google.protobuf import json_format from google.cloud.firestore_v1.types import document from google.cloud.firestore_v1.types import firestore from google.cloud.firestore_v1.types import tests @@ -107,11 +106,17 @@ def _run_testcase(testcase, call, firestore_api, client): call() else: call() + + wrapped_writes = [write.Write(write_pb) for write_pb in testcase.request.writes] + + expected_request = { + "database": client._database_string, + "writes": wrapped_writes, + "transaction": None, + } + firestore_api.commit.assert_called_once_with( - client._database_string, - list(testcase.request.writes), - transaction=None, - metadata=client._rpc_metadata, + request=expected_request, metadata=client._rpc_metadata, ) @@ -135,18 +140,24 @@ def test_get_testprotos(test_proto): doc.get() # No '.textprotos' for errors, field_paths. + expected_request = { + "name": doc._document_path, + "mask": None, + "transaction": None, + } + firestore_api.get_document.assert_called_once_with( - doc._document_path, mask=None, transaction=None, metadata=client._rpc_metadata, + request=expected_request, metadata=client._rpc_metadata, ) @pytest.mark.parametrize("test_proto", _SET_TESTPROTOS) def test_set_testprotos(test_proto): - testcase = test_proto.set + testcase = test_proto.set_ firestore_api = _mock_firestore_api() client, doc = _make_client_document(firestore_api, testcase) data = convert_data(json.loads(testcase.json_data)) - if testcase.HasField("option"): + if "option" in testcase: merge = convert_set_option(testcase.option) else: merge = False @@ -160,7 +171,7 @@ def test_update_testprotos(test_proto): firestore_api = _mock_firestore_api() client, doc = _make_client_document(firestore_api, testcase) data = convert_data(json.loads(testcase.json_data)) - if testcase.HasField("precondition"): + if "precondition" in testcase: option = convert_precondition(testcase.precondition) else: option = None @@ -179,7 +190,7 @@ def test_delete_testprotos(test_proto): testcase = test_proto.delete firestore_api = _mock_firestore_api() client, doc = _make_client_document(firestore_api, testcase) - if testcase.HasField("precondition"): + if "precondition" in testcase: option = convert_precondition(testcase.precondition) else: option = None @@ -227,9 +238,12 @@ def callback(keys, applied_changes, read_time): db_str = "projects/projectID/databases/(default)" watch._firestore._database_string_internal = db_str + wrapped_responses = [ + firestore.ListenResponse(proto) for proto in testcase.responses + ] if testcase.is_error: try: - for proto in testcase.responses: + for proto in wrapped_responses: watch.on_snapshot(proto) except RuntimeError: # listen-target-add-wrong-id.textpro @@ -237,7 +251,7 @@ def callback(keys, applied_changes, read_time): pass else: - for proto in testcase.responses: + for proto in wrapped_responses: watch.on_snapshot(proto) assert len(snapshots) == len(testcase.snapshots) @@ -310,7 +324,7 @@ def convert_set_option(option): _helpers.FieldPath(*field.field).to_api_repr() for field in option.fields ] - assert option.all + assert option.all_ return True @@ -482,7 +496,7 @@ def parse_cursor(cursor, client): from google.cloud.firestore_v1 import DocumentReference from google.cloud.firestore_v1 import DocumentSnapshot - if cursor.HasField("doc_snapshot"): + if "doc_snapshot" in cursor: path = parse_path(cursor.doc_snapshot.path) doc_ref = DocumentReference(*path, client=client) From 0e4270bcddfc1710492f267e495f32e543c3457f Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 6 Oct 2020 16:15:53 -0400 Subject: [PATCH 09/10] fix: use proto-plus message 'wrap' method for clarity --- tests/unit/v1/test_cross_language.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit/v1/test_cross_language.py b/tests/unit/v1/test_cross_language.py index 67c8c952f6..a1eafe63a3 100644 --- a/tests/unit/v1/test_cross_language.py +++ b/tests/unit/v1/test_cross_language.py @@ -107,7 +107,9 @@ def _run_testcase(testcase, call, firestore_api, client): else: call() - wrapped_writes = [write.Write(write_pb) for write_pb in testcase.request.writes] + wrapped_writes = [ + write.Write.wrap(write_pb) for write_pb in testcase.request.writes + ] expected_request = { "database": client._database_string, @@ -239,7 +241,7 @@ def callback(keys, applied_changes, read_time): watch._firestore._database_string_internal = db_str wrapped_responses = [ - firestore.ListenResponse(proto) for proto in testcase.responses + firestore.ListenResponse.wrap(proto) for proto in testcase.responses ] if testcase.is_error: try: From dbc8ca86058a2416f1d65b58835c519bceede85b Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 6 Oct 2020 17:29:07 -0400 Subject: [PATCH 10/10] tests: move generated conftest module to 'tests/unit/v1' --- Makefile_v1 | 6 +++++- .../types/tests.py => tests/unit/v1/conformance_tests.py | 2 +- tests/unit/v1/test_cross_language.py | 7 +++---- 3 files changed, 9 insertions(+), 6 deletions(-) rename google/cloud/firestore_v1/types/tests.py => tests/unit/v1/conformance_tests.py (99%) diff --git a/Makefile_v1 b/Makefile_v1 index eb783031ca..1648687e27 100644 --- a/Makefile_v1 +++ b/Makefile_v1 @@ -16,6 +16,7 @@ TESTDATA_DIR = `pwd`/tests/unit/v1/testdata/ TMPDIR = /tmp/python-fs-proto TMPDIR_FS = $(TMPDIR)/google/cloud/firestore_v1/types TEST_PROTO_COPY = $(TMPDIR_FS)/tests.proto +TEST_GEN_OUT = tests/unit/v1/conformance_tests.py OUTDIR = /tmp/python-fs-gen .PHONY: sync-protos gen-protos docker-pull @@ -31,7 +32,10 @@ gen-protos-raw: --user `id -u`:`id -g` \ gcr.io/gapic-images/gapic-generator-python cp $(OUTDIR)/google/cloud/firestore_v1/types/tests.py \ - google/cloud/firestore_v1/types/ + $(TEST_GEN_OUT) + sed -i -e \ + "s@package='google.cloud.firestore_v1'@package='tests.unit.v1'@" \ + $(TEST_GEN_OUT) tweak-protos: mkdir -p $(TMPDIR_FS) diff --git a/google/cloud/firestore_v1/types/tests.py b/tests/unit/v1/conformance_tests.py similarity index 99% rename from google/cloud/firestore_v1/types/tests.py rename to tests/unit/v1/conformance_tests.py index cfccb5beee..0718f8e5f4 100644 --- a/google/cloud/firestore_v1/types/tests.py +++ b/tests/unit/v1/conformance_tests.py @@ -26,7 +26,7 @@ __protobuf__ = proto.module( - package="google.cloud.firestore_v1", + package="tests.unit.v1", manifest={ "TestFile", "Test", diff --git a/tests/unit/v1/test_cross_language.py b/tests/unit/v1/test_cross_language.py index a1eafe63a3..49bc11506e 100644 --- a/tests/unit/v1/test_cross_language.py +++ b/tests/unit/v1/test_cross_language.py @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# TODO(microgen): currently cross language tests don't run as part of test pass -# This should be updated (and its makefile) to generate like other proto classes import functools import glob import json @@ -24,9 +22,10 @@ from google.cloud.firestore_v1.types import document from google.cloud.firestore_v1.types import firestore -from google.cloud.firestore_v1.types import tests from google.cloud.firestore_v1.types import write +from tests.unit.v1 import conformance_tests + def _load_test_json(filename): shortname = os.path.split(filename)[-1] @@ -34,7 +33,7 @@ def _load_test_json(filename): with open(filename, "r") as tp_file: tp_json = tp_file.read() - test_file = tests.TestFile.from_json(tp_json) + test_file = conformance_tests.TestFile.from_json(tp_json) for test_proto in test_file.tests: test_proto.description = test_proto.description + " (%s)" % shortname