diff --git a/firestore/tests/unit/testdata/create-all-transforms.textproto b/firestore/tests/unit/testdata/create-all-transforms.textproto new file mode 100644 index 000000000000..bbdf19e4df4a --- /dev/null +++ b/firestore/tests/unit/testdata/create-all-transforms.textproto @@ -0,0 +1,64 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can be created with any amount of transforms. + +description: "create: all transforms in a single call" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": [\"ArrayUnion\", 1, 2, 3], \"d\": [\"ArrayRemove\", 4, 5, 6]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + current_document: < + exists: false + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + set_to_server_value: REQUEST_TIME + > + field_transforms: < + field_path: "c" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "d" + remove_all_from_array: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/create-arrayremove-multi.textproto b/firestore/tests/unit/testdata/create-arrayremove-multi.textproto new file mode 100644 index 000000000000..f80d65b2381a --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayremove-multi.textproto @@ -0,0 +1,61 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can have more than one ArrayRemove field. Since all the ArrayRemove +# fields are removed, the only field in the update is "a". + +description: "create: multiple ArrayRemove fields" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3], \"c\": {\"d\": [\"ArrayRemove\", 4, 5, 6]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + current_document: < + exists: false + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "c.d" + remove_all_from_array: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/create-arrayremove-nested.textproto b/firestore/tests/unit/testdata/create-arrayremove-nested.textproto new file mode 100644 index 000000000000..97756c306c18 --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayremove-nested.textproto @@ -0,0 +1,48 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# An ArrayRemove value can occur at any depth. In this case, the transform applies +# to the field path "b.c". Since "c" is removed from the update, "b" becomes +# empty, so it is also removed from the update. + +description: "create: nested ArrayRemove field" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": {\"c\": [\"ArrayRemove\", 1, 2, 3]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + current_document: < + exists: false + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b.c" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/create-arrayremove-noarray-nested.textproto b/firestore/tests/unit/testdata/create-arrayremove-noarray-nested.textproto new file mode 100644 index 000000000000..4ec0cb3b9376 --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayremove-noarray-nested.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# There cannot be an array value anywhere on the path from the document root to +# the ArrayRemove. Firestore transforms don't support array indexing. + +description: "create: ArrayRemove cannot be anywhere inside an array value" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, {\"b\": [\"ArrayRemove\", 1, 2, 3]}]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/create-arrayremove-noarray.textproto b/firestore/tests/unit/testdata/create-arrayremove-noarray.textproto new file mode 100644 index 000000000000..969b8d9dd84e --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayremove-noarray.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayRemove must be the value of a field. Firestore transforms don't support +# array indexing. + +description: "create: ArrayRemove cannot be in an array value" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/create-arrayremove-with-st.textproto b/firestore/tests/unit/testdata/create-arrayremove-with-st.textproto new file mode 100644 index 000000000000..b6ea3224de73 --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayremove-with-st.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# The ServerTimestamp sentinel must be the value of a field. It may not appear in +# an ArrayUnion. + +description: "create: The ServerTimestamp sentinel cannot be in an ArrayUnion" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [\"ArrayRemove\", 1, \"ServerTimestamp\", 3]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/create-arrayremove.textproto b/firestore/tests/unit/testdata/create-arrayremove.textproto new file mode 100644 index 000000000000..e8e4bb3980db --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayremove.textproto @@ -0,0 +1,47 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A key with ArrayRemove is removed from the data in the update operation. Instead +# it appears in a separate Transform operation. + +description: "create: ArrayRemove with data" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + current_document: < + exists: false + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/create-arrayunion-multi.textproto b/firestore/tests/unit/testdata/create-arrayunion-multi.textproto new file mode 100644 index 000000000000..ec3cb72f5b1b --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayunion-multi.textproto @@ -0,0 +1,61 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can have more than one ArrayUnion field. Since all the ArrayUnion +# fields are removed, the only field in the update is "a". + +description: "create: multiple ArrayUnion fields" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3], \"c\": {\"d\": [\"ArrayUnion\", 4, 5, 6]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + current_document: < + exists: false + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "c.d" + append_missing_elements: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/create-arrayunion-nested.textproto b/firestore/tests/unit/testdata/create-arrayunion-nested.textproto new file mode 100644 index 000000000000..e6e81bc1d7a2 --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayunion-nested.textproto @@ -0,0 +1,48 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# An ArrayUnion value can occur at any depth. In this case, the transform applies +# to the field path "b.c". Since "c" is removed from the update, "b" becomes +# empty, so it is also removed from the update. + +description: "create: nested ArrayUnion field" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": {\"c\": [\"ArrayUnion\", 1, 2, 3]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + current_document: < + exists: false + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b.c" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/create-arrayunion-noarray-nested.textproto b/firestore/tests/unit/testdata/create-arrayunion-noarray-nested.textproto new file mode 100644 index 000000000000..4c0afe443048 --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayunion-noarray-nested.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# There cannot be an array value anywhere on the path from the document root to +# the ArrayUnion. Firestore transforms don't support array indexing. + +description: "create: ArrayUnion cannot be anywhere inside an array value" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, {\"b\": [\"ArrayUnion\", 1, 2, 3]}]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/create-arrayunion-noarray.textproto b/firestore/tests/unit/testdata/create-arrayunion-noarray.textproto new file mode 100644 index 000000000000..7b791fa4154d --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayunion-noarray.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayUnion must be the value of a field. Firestore transforms don't support +# array indexing. + +description: "create: ArrayUnion cannot be in an array value" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/create-arrayunion-with-st.textproto b/firestore/tests/unit/testdata/create-arrayunion-with-st.textproto new file mode 100644 index 000000000000..a1bf4a90d1c4 --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayunion-with-st.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# The ServerTimestamp sentinel must be the value of a field. It may not appear in +# an ArrayUnion. + +description: "create: The ServerTimestamp sentinel cannot be in an ArrayUnion" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [\"ArrayUnion\", 1, \"ServerTimestamp\", 3]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/create-arrayunion.textproto b/firestore/tests/unit/testdata/create-arrayunion.textproto new file mode 100644 index 000000000000..98cb6ad8acb1 --- /dev/null +++ b/firestore/tests/unit/testdata/create-arrayunion.textproto @@ -0,0 +1,47 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A key with ArrayUnion is removed from the data in the update operation. Instead +# it appears in a separate Transform operation. + +description: "create: ArrayUnion with data" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + current_document: < + exists: false + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/create-st-with-empty-map.textproto b/firestore/tests/unit/testdata/create-st-with-empty-map.textproto new file mode 100644 index 000000000000..37e7e074abec --- /dev/null +++ b/firestore/tests/unit/testdata/create-st-with-empty-map.textproto @@ -0,0 +1,45 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# When a ServerTimestamp and a map both reside inside a map, the ServerTimestamp +# should be stripped out but the empty map should remain. + +description: "create: ServerTimestamp beside an empty map" +create: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": {\"b\": {}, \"c\": \"ServerTimestamp\"}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + map_value: < + fields: < + key: "b" + value: < + map_value: < + > + > + > + > + > + > + > + current_document: < + exists: false + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "a.c" + set_to_server_value: REQUEST_TIME + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/query-arrayremove-cursor.textproto b/firestore/tests/unit/testdata/query-arrayremove-cursor.textproto new file mode 100644 index 000000000000..3c926da963e6 --- /dev/null +++ b/firestore/tests/unit/testdata/query-arrayremove-cursor.textproto @@ -0,0 +1,23 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayRemove is not permitted in queries. + +description: "query: ArrayRemove in cursor method" +query: < + coll_path: "projects/projectID/databases/(default)/documents/C" + clauses: < + order_by: < + path: < + field: "a" + > + direction: "asc" + > + > + clauses: < + end_before: < + json_values: "[\"ArrayRemove\", 1, 2, 3]" + > + > + is_error: true +> diff --git a/firestore/tests/unit/testdata/query-arrayremove-where.textproto b/firestore/tests/unit/testdata/query-arrayremove-where.textproto new file mode 100644 index 000000000000..000b76350e01 --- /dev/null +++ b/firestore/tests/unit/testdata/query-arrayremove-where.textproto @@ -0,0 +1,19 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayRemove is not permitted in queries. + +description: "query: ArrayRemove in Where" +query: < + coll_path: "projects/projectID/databases/(default)/documents/C" + clauses: < + where: < + path: < + field: "a" + > + op: "==" + json_value: "[\"ArrayRemove\", 1, 2, 3]" + > + > + is_error: true +> diff --git a/firestore/tests/unit/testdata/query-arrayunion-cursor.textproto b/firestore/tests/unit/testdata/query-arrayunion-cursor.textproto new file mode 100644 index 000000000000..e8a61104d1b3 --- /dev/null +++ b/firestore/tests/unit/testdata/query-arrayunion-cursor.textproto @@ -0,0 +1,23 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayUnion is not permitted in queries. + +description: "query: ArrayUnion in cursor method" +query: < + coll_path: "projects/projectID/databases/(default)/documents/C" + clauses: < + order_by: < + path: < + field: "a" + > + direction: "asc" + > + > + clauses: < + end_before: < + json_values: "[\"ArrayUnion\", 1, 2, 3]" + > + > + is_error: true +> diff --git a/firestore/tests/unit/testdata/query-arrayunion-where.textproto b/firestore/tests/unit/testdata/query-arrayunion-where.textproto new file mode 100644 index 000000000000..94923134e2b1 --- /dev/null +++ b/firestore/tests/unit/testdata/query-arrayunion-where.textproto @@ -0,0 +1,19 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayUnion is not permitted in queries. + +description: "query: ArrayUnion in Where" +query: < + coll_path: "projects/projectID/databases/(default)/documents/C" + clauses: < + where: < + path: < + field: "a" + > + op: "==" + json_value: "[\"ArrayUnion\", 1, 2, 3]" + > + > + is_error: true +> diff --git a/firestore/tests/unit/testdata/set-all-transforms.textproto b/firestore/tests/unit/testdata/set-all-transforms.textproto new file mode 100644 index 000000000000..bf18f9a5b12a --- /dev/null +++ b/firestore/tests/unit/testdata/set-all-transforms.textproto @@ -0,0 +1,61 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can be created with any amount of transforms. + +description: "set: all transforms in a single call" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": [\"ArrayUnion\", 1, 2, 3], \"d\": [\"ArrayRemove\", 4, 5, 6]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + set_to_server_value: REQUEST_TIME + > + field_transforms: < + field_path: "c" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "d" + remove_all_from_array: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/set-arrayremove-multi.textproto b/firestore/tests/unit/testdata/set-arrayremove-multi.textproto new file mode 100644 index 000000000000..9b62fe191953 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayremove-multi.textproto @@ -0,0 +1,58 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can have more than one ArrayRemove field. Since all the ArrayRemove +# fields are removed, the only field in the update is "a". + +description: "set: multiple ArrayRemove fields" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3], \"c\": {\"d\": [\"ArrayRemove\", 4, 5, 6]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "c.d" + remove_all_from_array: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/set-arrayremove-nested.textproto b/firestore/tests/unit/testdata/set-arrayremove-nested.textproto new file mode 100644 index 000000000000..617609c5a39e --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayremove-nested.textproto @@ -0,0 +1,45 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# An ArrayRemove value can occur at any depth. In this case, the transform applies +# to the field path "b.c". Since "c" is removed from the update, "b" becomes +# empty, so it is also removed from the update. + +description: "set: nested ArrayRemove field" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": {\"c\": [\"ArrayRemove\", 1, 2, 3]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b.c" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/set-arrayremove-noarray-nested.textproto b/firestore/tests/unit/testdata/set-arrayremove-noarray-nested.textproto new file mode 100644 index 000000000000..2efa34a59f19 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayremove-noarray-nested.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# There cannot be an array value anywhere on the path from the document root to +# the ArrayRemove. Firestore transforms don't support array indexing. + +description: "set: ArrayRemove cannot be anywhere inside an array value" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, {\"b\": [\"ArrayRemove\", 1, 2, 3]}]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/set-arrayremove-noarray.textproto b/firestore/tests/unit/testdata/set-arrayremove-noarray.textproto new file mode 100644 index 000000000000..e7aa209ea22b --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayremove-noarray.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayRemove must be the value of a field. Firestore transforms don't support +# array indexing. + +description: "set: ArrayRemove cannot be in an array value" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/set-arrayremove-with-st.textproto b/firestore/tests/unit/testdata/set-arrayremove-with-st.textproto new file mode 100644 index 000000000000..353025b59ff5 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayremove-with-st.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# The ServerTimestamp sentinel must be the value of a field. It may not appear in +# an ArrayUnion. + +description: "set: The ServerTimestamp sentinel cannot be in an ArrayUnion" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [\"ArrayRemove\", 1, \"ServerTimestamp\", 3]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/set-arrayremove.textproto b/firestore/tests/unit/testdata/set-arrayremove.textproto new file mode 100644 index 000000000000..8aa6b60d0156 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayremove.textproto @@ -0,0 +1,44 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A key with ArrayRemove is removed from the data in the update operation. Instead +# it appears in a separate Transform operation. + +description: "set: ArrayRemove with data" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/set-arrayunion-multi.textproto b/firestore/tests/unit/testdata/set-arrayunion-multi.textproto new file mode 100644 index 000000000000..e515bfa8d188 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayunion-multi.textproto @@ -0,0 +1,58 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can have more than one ArrayUnion field. Since all the ArrayUnion +# fields are removed, the only field in the update is "a". + +description: "set: multiple ArrayUnion fields" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3], \"c\": {\"d\": [\"ArrayUnion\", 4, 5, 6]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "c.d" + append_missing_elements: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/set-arrayunion-nested.textproto b/firestore/tests/unit/testdata/set-arrayunion-nested.textproto new file mode 100644 index 000000000000..f8abeb0d0004 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayunion-nested.textproto @@ -0,0 +1,45 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# An ArrayUnion value can occur at any depth. In this case, the transform applies +# to the field path "b.c". Since "c" is removed from the update, "b" becomes +# empty, so it is also removed from the update. + +description: "set: nested ArrayUnion field" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": {\"c\": [\"ArrayUnion\", 1, 2, 3]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b.c" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/set-arrayunion-noarray-nested.textproto b/firestore/tests/unit/testdata/set-arrayunion-noarray-nested.textproto new file mode 100644 index 000000000000..2b4170f431a3 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayunion-noarray-nested.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# There cannot be an array value anywhere on the path from the document root to +# the ArrayUnion. Firestore transforms don't support array indexing. + +description: "set: ArrayUnion cannot be anywhere inside an array value" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, {\"b\": [\"ArrayUnion\", 1, 2, 3]}]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/set-arrayunion-noarray.textproto b/firestore/tests/unit/testdata/set-arrayunion-noarray.textproto new file mode 100644 index 000000000000..e08af3a07f14 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayunion-noarray.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayUnion must be the value of a field. Firestore transforms don't support +# array indexing. + +description: "set: ArrayUnion cannot be in an array value" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/set-arrayunion-with-st.textproto b/firestore/tests/unit/testdata/set-arrayunion-with-st.textproto new file mode 100644 index 000000000000..37a7a132e750 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayunion-with-st.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# The ServerTimestamp sentinel must be the value of a field. It may not appear in +# an ArrayUnion. + +description: "set: The ServerTimestamp sentinel cannot be in an ArrayUnion" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [\"ArrayUnion\", 1, \"ServerTimestamp\", 3]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/set-arrayunion.textproto b/firestore/tests/unit/testdata/set-arrayunion.textproto new file mode 100644 index 000000000000..4751e0c0e322 --- /dev/null +++ b/firestore/tests/unit/testdata/set-arrayunion.textproto @@ -0,0 +1,44 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A key with ArrayUnion is removed from the data in the update operation. Instead +# it appears in a separate Transform operation. + +description: "set: ArrayUnion with data" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/set-st-with-empty-map.textproto b/firestore/tests/unit/testdata/set-st-with-empty-map.textproto new file mode 100644 index 000000000000..5e187983f995 --- /dev/null +++ b/firestore/tests/unit/testdata/set-st-with-empty-map.textproto @@ -0,0 +1,42 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# When a ServerTimestamp and a map both reside inside a map, the ServerTimestamp +# should be stripped out but the empty map should remain. + +description: "set: ServerTimestamp beside an empty map" +set: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": {\"b\": {}, \"c\": \"ServerTimestamp\"}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + map_value: < + fields: < + key: "b" + value: < + map_value: < + > + > + > + > + > + > + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "a.c" + set_to_server_value: REQUEST_TIME + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/test-suite.binproto b/firestore/tests/unit/testdata/test-suite.binproto index 38b7e8804682..0619a2fc130a 100644 Binary files a/firestore/tests/unit/testdata/test-suite.binproto and b/firestore/tests/unit/testdata/test-suite.binproto differ diff --git a/firestore/tests/unit/testdata/update-all-transforms.textproto b/firestore/tests/unit/testdata/update-all-transforms.textproto new file mode 100644 index 000000000000..225cc61e405e --- /dev/null +++ b/firestore/tests/unit/testdata/update-all-transforms.textproto @@ -0,0 +1,67 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can be created with any amount of transforms. + +description: "update: all transforms in a single call" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": [\"ArrayUnion\", 1, 2, 3], \"d\": [\"ArrayRemove\", 4, 5, 6]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + set_to_server_value: REQUEST_TIME + > + field_transforms: < + field_path: "c" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "d" + remove_all_from_array: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-arrayremove-alone.textproto b/firestore/tests/unit/testdata/update-arrayremove-alone.textproto new file mode 100644 index 000000000000..8c79a31d5052 --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayremove-alone.textproto @@ -0,0 +1,36 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# If the only values in the input are ArrayRemove, then no update operation should +# be produced. + +description: "update: ArrayRemove alone" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [\"ArrayRemove\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "a" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + current_document: < + exists: true + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-arrayremove-multi.textproto b/firestore/tests/unit/testdata/update-arrayremove-multi.textproto new file mode 100644 index 000000000000..2362b6e09458 --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayremove-multi.textproto @@ -0,0 +1,69 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can have more than one ArrayRemove field. Since all the ArrayRemove +# fields are removed, the only field in the update is "a". + +# b is not in the mask because it will be set in the transform. c must be in the +# mask: it should be replaced entirely. The transform will set c.d to the +# timestamp, but the update will delete the rest of c. + +description: "update: multiple ArrayRemove fields" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3], \"c\": {\"d\": [\"ArrayRemove\", 4, 5, 6]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + field_paths: "c" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "c.d" + remove_all_from_array: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-arrayremove-nested.textproto b/firestore/tests/unit/testdata/update-arrayremove-nested.textproto new file mode 100644 index 000000000000..143790179eaf --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayremove-nested.textproto @@ -0,0 +1,52 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# An ArrayRemove value can occur at any depth. In this case, the transform applies +# to the field path "b.c". Since "c" is removed from the update, "b" becomes +# empty, so it is also removed from the update. + +description: "update: nested ArrayRemove field" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": {\"c\": [\"ArrayRemove\", 1, 2, 3]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + field_paths: "b" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b.c" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-arrayremove-noarray-nested.textproto b/firestore/tests/unit/testdata/update-arrayremove-noarray-nested.textproto new file mode 100644 index 000000000000..04eca965c688 --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayremove-noarray-nested.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# There cannot be an array value anywhere on the path from the document root to +# the ArrayRemove. Firestore transforms don't support array indexing. + +description: "update: ArrayRemove cannot be anywhere inside an array value" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, {\"b\": [\"ArrayRemove\", 1, 2, 3]}]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-arrayremove-noarray.textproto b/firestore/tests/unit/testdata/update-arrayremove-noarray.textproto new file mode 100644 index 000000000000..bbd27bf017e1 --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayremove-noarray.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayRemove must be the value of a field. Firestore transforms don't support +# array indexing. + +description: "update: ArrayRemove cannot be in an array value" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-arrayremove-with-st.textproto b/firestore/tests/unit/testdata/update-arrayremove-with-st.textproto new file mode 100644 index 000000000000..4888b44f1c01 --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayremove-with-st.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# The ServerTimestamp sentinel must be the value of a field. It may not appear in +# an ArrayUnion. + +description: "update: The ServerTimestamp sentinel cannot be in an ArrayUnion" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [\"ArrayRemove\", 1, \"ServerTimestamp\", 3]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-arrayremove.textproto b/firestore/tests/unit/testdata/update-arrayremove.textproto new file mode 100644 index 000000000000..3b767cf486c3 --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayremove.textproto @@ -0,0 +1,50 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A key with ArrayRemove is removed from the data in the update operation. Instead +# it appears in a separate Transform operation. + +description: "update: ArrayRemove with data" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-arrayunion-alone.textproto b/firestore/tests/unit/testdata/update-arrayunion-alone.textproto new file mode 100644 index 000000000000..ec12818da74c --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayunion-alone.textproto @@ -0,0 +1,36 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# If the only values in the input are ArrayUnion, then no update operation should +# be produced. + +description: "update: ArrayUnion alone" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [\"ArrayUnion\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "a" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + current_document: < + exists: true + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-arrayunion-multi.textproto b/firestore/tests/unit/testdata/update-arrayunion-multi.textproto new file mode 100644 index 000000000000..8edf6a3af046 --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayunion-multi.textproto @@ -0,0 +1,69 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can have more than one ArrayUnion field. Since all the ArrayUnion +# fields are removed, the only field in the update is "a". + +# b is not in the mask because it will be set in the transform. c must be in the +# mask: it should be replaced entirely. The transform will set c.d to the +# timestamp, but the update will delete the rest of c. + +description: "update: multiple ArrayUnion fields" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3], \"c\": {\"d\": [\"ArrayUnion\", 4, 5, 6]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + field_paths: "c" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "c.d" + append_missing_elements: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-arrayunion-nested.textproto b/firestore/tests/unit/testdata/update-arrayunion-nested.textproto new file mode 100644 index 000000000000..217e2e2ca775 --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayunion-nested.textproto @@ -0,0 +1,52 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# An ArrayUnion value can occur at any depth. In this case, the transform applies +# to the field path "b.c". Since "c" is removed from the update, "b" becomes +# empty, so it is also removed from the update. + +description: "update: nested ArrayUnion field" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": {\"c\": [\"ArrayUnion\", 1, 2, 3]}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + field_paths: "b" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b.c" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-arrayunion-noarray-nested.textproto b/firestore/tests/unit/testdata/update-arrayunion-noarray-nested.textproto new file mode 100644 index 000000000000..0326781830ec --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayunion-noarray-nested.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# There cannot be an array value anywhere on the path from the document root to +# the ArrayUnion. Firestore transforms don't support array indexing. + +description: "update: ArrayUnion cannot be anywhere inside an array value" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, {\"b\": [\"ArrayUnion\", 1, 2, 3]}]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-arrayunion-noarray.textproto b/firestore/tests/unit/testdata/update-arrayunion-noarray.textproto new file mode 100644 index 000000000000..c199f9f73c91 --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayunion-noarray.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayUnion must be the value of a field. Firestore transforms don't support +# array indexing. + +description: "update: ArrayUnion cannot be in an array value" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-arrayunion-with-st.textproto b/firestore/tests/unit/testdata/update-arrayunion-with-st.textproto new file mode 100644 index 000000000000..ee022f8492bc --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayunion-with-st.textproto @@ -0,0 +1,12 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# The ServerTimestamp sentinel must be the value of a field. It may not appear in +# an ArrayUnion. + +description: "update: The ServerTimestamp sentinel cannot be in an ArrayUnion" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": [\"ArrayUnion\", 1, \"ServerTimestamp\", 3]}" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-arrayunion.textproto b/firestore/tests/unit/testdata/update-arrayunion.textproto new file mode 100644 index 000000000000..81b240b891bb --- /dev/null +++ b/firestore/tests/unit/testdata/update-arrayunion.textproto @@ -0,0 +1,50 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A key with ArrayUnion is removed from the data in the update operation. Instead +# it appears in a separate Transform operation. + +description: "update: ArrayUnion with data" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-all-transforms.textproto b/firestore/tests/unit/testdata/update-paths-all-transforms.textproto new file mode 100644 index 000000000000..8cfad4732034 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-all-transforms.textproto @@ -0,0 +1,82 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can be created with any amount of transforms. + +description: "update-paths: all transforms in a single call" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + field_paths: < + field: "b" + > + field_paths: < + field: "c" + > + field_paths: < + field: "d" + > + json_values: "1" + json_values: "\"ServerTimestamp\"" + json_values: "[\"ArrayUnion\", 1, 2, 3]" + json_values: "[\"ArrayRemove\", 4, 5, 6]" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + set_to_server_value: REQUEST_TIME + > + field_transforms: < + field_path: "c" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "d" + remove_all_from_array: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayremove-alone.textproto b/firestore/tests/unit/testdata/update-paths-arrayremove-alone.textproto new file mode 100644 index 000000000000..68f0e147b2de --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayremove-alone.textproto @@ -0,0 +1,39 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# If the only values in the input are ArrayRemove, then no update operation should +# be produced. + +description: "update-paths: ArrayRemove alone" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + json_values: "[\"ArrayRemove\", 1, 2, 3]" + request: < + database: "projects/projectID/databases/(default)" + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "a" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + current_document: < + exists: true + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayremove-multi.textproto b/firestore/tests/unit/testdata/update-paths-arrayremove-multi.textproto new file mode 100644 index 000000000000..b60c3f36a6c0 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayremove-multi.textproto @@ -0,0 +1,76 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can have more than one ArrayRemove field. Since all the ArrayRemove +# fields are removed, the only field in the update is "a". + +description: "update-paths: multiple ArrayRemove fields" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + field_paths: < + field: "b" + > + field_paths: < + field: "c" + > + json_values: "1" + json_values: "[\"ArrayRemove\", 1, 2, 3]" + json_values: "{\"d\": [\"ArrayRemove\", 4, 5, 6]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + field_paths: "c" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "c.d" + remove_all_from_array: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayremove-nested.textproto b/firestore/tests/unit/testdata/update-paths-arrayremove-nested.textproto new file mode 100644 index 000000000000..381be19d553f --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayremove-nested.textproto @@ -0,0 +1,59 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# An ArrayRemove value can occur at any depth. In this case, the transform applies +# to the field path "b.c". Since "c" is removed from the update, "b" becomes +# empty, so it is also removed from the update. + +description: "update-paths: nested ArrayRemove field" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + field_paths: < + field: "b" + > + json_values: "1" + json_values: "{\"c\": [\"ArrayRemove\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + field_paths: "b" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b.c" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayremove-noarray-nested.textproto b/firestore/tests/unit/testdata/update-paths-arrayremove-noarray-nested.textproto new file mode 100644 index 000000000000..35f6c67b2e56 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayremove-noarray-nested.textproto @@ -0,0 +1,15 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# There cannot be an array value anywhere on the path from the document root to +# the ArrayRemove. Firestore transforms don't support array indexing. + +description: "update-paths: ArrayRemove cannot be anywhere inside an array value" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + json_values: "[1, {\"b\": [\"ArrayRemove\", 1, 2, 3]}]" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayremove-noarray.textproto b/firestore/tests/unit/testdata/update-paths-arrayremove-noarray.textproto new file mode 100644 index 000000000000..45cab48dd9e1 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayremove-noarray.textproto @@ -0,0 +1,15 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayRemove must be the value of a field. Firestore transforms don't support +# array indexing. + +description: "update-paths: ArrayRemove cannot be in an array value" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + json_values: "[1, 2, [\"ArrayRemove\", 1, 2, 3]]" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayremove-with-st.textproto b/firestore/tests/unit/testdata/update-paths-arrayremove-with-st.textproto new file mode 100644 index 000000000000..67b92a3ef3b9 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayremove-with-st.textproto @@ -0,0 +1,15 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# The ServerTimestamp sentinel must be the value of a field. It may not appear in +# an ArrayUnion. + +description: "update-paths: The ServerTimestamp sentinel cannot be in an ArrayUnion" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + json_values: "[\"ArrayRemove\", 1, \"ServerTimestamp\", 3]" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayremove.textproto b/firestore/tests/unit/testdata/update-paths-arrayremove.textproto new file mode 100644 index 000000000000..d3866676ede0 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayremove.textproto @@ -0,0 +1,57 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A key with ArrayRemove is removed from the data in the update operation. Instead +# it appears in a separate Transform operation. + +description: "update-paths: ArrayRemove with data" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + field_paths: < + field: "b" + > + json_values: "1" + json_values: "[\"ArrayRemove\", 1, 2, 3]" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + remove_all_from_array: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayunion-alone.textproto b/firestore/tests/unit/testdata/update-paths-arrayunion-alone.textproto new file mode 100644 index 000000000000..48100e0abceb --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayunion-alone.textproto @@ -0,0 +1,39 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# If the only values in the input are ArrayUnion, then no update operation should +# be produced. + +description: "update-paths: ArrayUnion alone" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + json_values: "[\"ArrayUnion\", 1, 2, 3]" + request: < + database: "projects/projectID/databases/(default)" + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "a" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + current_document: < + exists: true + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayunion-multi.textproto b/firestore/tests/unit/testdata/update-paths-arrayunion-multi.textproto new file mode 100644 index 000000000000..03772e5ddd1a --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayunion-multi.textproto @@ -0,0 +1,76 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A document can have more than one ArrayUnion field. Since all the ArrayUnion +# fields are removed, the only field in the update is "a". + +description: "update-paths: multiple ArrayUnion fields" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + field_paths: < + field: "b" + > + field_paths: < + field: "c" + > + json_values: "1" + json_values: "[\"ArrayUnion\", 1, 2, 3]" + json_values: "{\"d\": [\"ArrayUnion\", 4, 5, 6]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + field_paths: "c" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + field_transforms: < + field_path: "c.d" + append_missing_elements: < + values: < + integer_value: 4 + > + values: < + integer_value: 5 + > + values: < + integer_value: 6 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayunion-nested.textproto b/firestore/tests/unit/testdata/update-paths-arrayunion-nested.textproto new file mode 100644 index 000000000000..1420e4e2806b --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayunion-nested.textproto @@ -0,0 +1,59 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# An ArrayUnion value can occur at any depth. In this case, the transform applies +# to the field path "b.c". Since "c" is removed from the update, "b" becomes +# empty, so it is also removed from the update. + +description: "update-paths: nested ArrayUnion field" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + field_paths: < + field: "b" + > + json_values: "1" + json_values: "{\"c\": [\"ArrayUnion\", 1, 2, 3]}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + field_paths: "b" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b.c" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayunion-noarray-nested.textproto b/firestore/tests/unit/testdata/update-paths-arrayunion-noarray-nested.textproto new file mode 100644 index 000000000000..ab75bf38a3ae --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayunion-noarray-nested.textproto @@ -0,0 +1,15 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# There cannot be an array value anywhere on the path from the document root to +# the ArrayUnion. Firestore transforms don't support array indexing. + +description: "update-paths: ArrayUnion cannot be anywhere inside an array value" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + json_values: "[1, {\"b\": [\"ArrayUnion\", 1, 2, 3]}]" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayunion-noarray.textproto b/firestore/tests/unit/testdata/update-paths-arrayunion-noarray.textproto new file mode 100644 index 000000000000..fac72644fc38 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayunion-noarray.textproto @@ -0,0 +1,15 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# ArrayUnion must be the value of a field. Firestore transforms don't support +# array indexing. + +description: "update-paths: ArrayUnion cannot be in an array value" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + json_values: "[1, 2, [\"ArrayRemove\", 1, 2, 3]]" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayunion-with-st.textproto b/firestore/tests/unit/testdata/update-paths-arrayunion-with-st.textproto new file mode 100644 index 000000000000..d194c09bd775 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayunion-with-st.textproto @@ -0,0 +1,15 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# The ServerTimestamp sentinel must be the value of a field. It may not appear in +# an ArrayUnion. + +description: "update-paths: The ServerTimestamp sentinel cannot be in an ArrayUnion" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + json_values: "[\"ArrayUnion\", 1, \"ServerTimestamp\", 3]" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-paths-arrayunion.textproto b/firestore/tests/unit/testdata/update-paths-arrayunion.textproto new file mode 100644 index 000000000000..fc56c1e29471 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-arrayunion.textproto @@ -0,0 +1,57 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# A key with ArrayUnion is removed from the data in the update operation. Instead +# it appears in a separate Transform operation. + +description: "update-paths: ArrayUnion with data" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + field_paths: < + field: "b" + > + json_values: "1" + json_values: "[\"ArrayUnion\", 1, 2, 3]" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + integer_value: 1 + > + > + > + update_mask: < + field_paths: "a" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "b" + append_missing_elements: < + values: < + integer_value: 1 + > + values: < + integer_value: 2 + > + values: < + integer_value: 3 + > + > + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-paths-fp-dup-transforms.textproto b/firestore/tests/unit/testdata/update-paths-fp-dup-transforms.textproto new file mode 100644 index 000000000000..a84725a8d4d1 --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-fp-dup-transforms.textproto @@ -0,0 +1,23 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# The same field cannot occur more than once, even if all the operations are +# transforms. + +description: "update-paths: duplicate field path with only transforms" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + field_paths: < + field: "b" + > + field_paths: < + field: "a" + > + json_values: "[\"ArrayUnion\", 1, 2, 3]" + json_values: "\"ServerTimestamp\"" + json_values: "[\"ArrayUnion\", 4, 5, 6]" + is_error: true +> diff --git a/firestore/tests/unit/testdata/update-paths-st-with-empty-map.textproto b/firestore/tests/unit/testdata/update-paths-st-with-empty-map.textproto new file mode 100644 index 000000000000..a54a241565de --- /dev/null +++ b/firestore/tests/unit/testdata/update-paths-st-with-empty-map.textproto @@ -0,0 +1,51 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# When a ServerTimestamp and a map both reside inside a map, the ServerTimestamp +# should be stripped out but the empty map should remain. + +description: "update-paths: ServerTimestamp beside an empty map" +update_paths: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + field_paths: < + field: "a" + > + json_values: "{\"b\": {}, \"c\": \"ServerTimestamp\"}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + map_value: < + fields: < + key: "b" + value: < + map_value: < + > + > + > + > + > + > + > + update_mask: < + field_paths: "a" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "a.c" + set_to_server_value: REQUEST_TIME + > + > + > + > +> diff --git a/firestore/tests/unit/testdata/update-st-with-empty-map.textproto b/firestore/tests/unit/testdata/update-st-with-empty-map.textproto new file mode 100644 index 000000000000..1901de2a15ef --- /dev/null +++ b/firestore/tests/unit/testdata/update-st-with-empty-map.textproto @@ -0,0 +1,48 @@ +# DO NOT MODIFY. This file was generated by +# github.com/GoogleCloudPlatform/google-cloud-common/testing/firestore/cmd/generate-firestore-tests/generate-firestore-tests.go. + +# When a ServerTimestamp and a map both reside inside a map, the ServerTimestamp +# should be stripped out but the empty map should remain. + +description: "update: ServerTimestamp beside an empty map" +update: < + doc_ref_path: "projects/projectID/databases/(default)/documents/C/d" + json_data: "{\"a\": {\"b\": {}, \"c\": \"ServerTimestamp\"}}" + request: < + database: "projects/projectID/databases/(default)" + writes: < + update: < + name: "projects/projectID/databases/(default)/documents/C/d" + fields: < + key: "a" + value: < + map_value: < + fields: < + key: "b" + value: < + map_value: < + > + > + > + > + > + > + > + update_mask: < + field_paths: "a" + > + current_document: < + exists: true + > + > + writes: < + transform: < + document: "projects/projectID/databases/(default)/documents/C/d" + field_transforms: < + field_path: "a.c" + set_to_server_value: REQUEST_TIME + > + > + > + > +>