Skip to content

Commit

Permalink
Port spec test changes from firebase/firebase-js-sdk#7229 (Optimize l…
Browse files Browse the repository at this point in the history
…ocal cache sync when resuming a query that had docs deleted)
  • Loading branch information
dconeybe committed Apr 24, 2023
1 parent c76b67c commit 0f870e9
Show file tree
Hide file tree
Showing 8 changed files with 7,643 additions and 773 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,22 @@ private Query parseQuery(Object querySpec) throws JSONException {
}
}

private static QueryPurpose parseQueryPurpose(Object value) {
if (!(value instanceof Integer)) {
throw new IllegalArgumentException("invalid query purpose: " + value);
}
switch ((Integer) value) {
case 0:
return QueryPurpose.LISTEN;
case 1:
return QueryPurpose.EXISTENCE_FILTER_MISMATCH;
case 3:
return QueryPurpose.LIMBO_RESOLUTION;
default:
throw new IllegalArgumentException("unknown query purpose value: " + value);
}
}

private DocumentViewChange parseChange(JSONObject jsonDoc, DocumentViewChange.Type type)
throws JSONException {
long version = jsonDoc.getLong("version");
Expand Down Expand Up @@ -1027,7 +1043,7 @@ private void validateExpectedState(@Nullable JSONObject expectedState) throws JS

QueryPurpose purpose = QueryPurpose.LISTEN;
if (queryDataJson.has("targetPurpose")) {
purpose = QueryPurpose.values()[queryDataJson.getInt("targetPurpose")];
purpose = parseQueryPurpose(queryDataJson.get("targetPurpose"));
}

TargetData targetData =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@
}
],
"resumeToken": "",
"targetPurpose": 2
"targetPurpose": 3
},
"2": {
"queries": [
Expand Down
Loading

0 comments on commit 0f870e9

Please sign in to comment.