Skip to content

Commit

Permalink
Add ArrayUnion/ArrayRemove conformance tests (#3704)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Sep 21, 2018
1 parent 36409f5 commit 9ab7770
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,19 @@ public int compare(QueryDocumentSnapshot o1, QueryDocumentSnapshot o2) {
}

/** Helper function to convert test values in a list to Firestore API types. */
private List<Object> convertArray(List<Object> list) {
for (int i = 0; i < list.size(); ++i) {
list.set(i, convertValue(list.get(i)));
private Object convertArray(List<Object> list) {
if (!list.isEmpty() && list.get(0).equals("ArrayUnion")) {
return FieldValue.arrayUnion(
((List<Object>) convertArray(list.subList(1, list.size()))).toArray());
} else if (!list.isEmpty() && list.get(0).equals("ArrayRemove")) {
return FieldValue.arrayRemove(
((List<Object>) convertArray(list.subList(1, list.size()))).toArray());
} else {
for (int i = 0; i < list.size(); ++i) {
list.set(i, convertValue(list.get(i)));
}
return list;
}
return list;
}

/** Reads the test definition from the Proto file. */
Expand Down
Binary file not shown.

0 comments on commit 9ab7770

Please sign in to comment.