From 4c9df5a6661e12d6b3d11f69746ff256f0526653 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 6 Jul 2018 20:46:00 +0200 Subject: Add spec test support for target-scoped resume tokens (#1498) --- .../Tests/SpecTests/json/listen_spec_test.json | 459 ++++++++++++++++++--- 1 file changed, 403 insertions(+), 56 deletions(-) (limited to 'Firestore/Example/Tests/SpecTests/json/listen_spec_test.json') diff --git a/Firestore/Example/Tests/SpecTests/json/listen_spec_test.json b/Firestore/Example/Tests/SpecTests/json/listen_spec_test.json index e838d2f..e1fb77f 100644 --- a/Firestore/Example/Tests/SpecTests/json/listen_spec_test.json +++ b/Firestore/Example/Tests/SpecTests/json/listen_spec_test.json @@ -2,7 +2,10 @@ "Contents of query are cleared when listen is removed.": { "describeName": "Listens:", "itName": "Contents of query are cleared when listen is removed.", - "tags": [], + "tags": [ + "no-lru" + ], + "comment": "Explicitly tests eager GC behavior", "config": { "useGarbageCollection": true }, @@ -56,8 +59,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -174,8 +181,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -212,8 +223,12 @@ "targets": [ 2 ] + } + }, + { + "watchSnapshot": { + "version": 2000 }, - "watchSnapshot": 2000, "expect": [ { "query": { @@ -373,8 +388,12 @@ { "watchAck": [ 6 - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -476,8 +495,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -559,7 +582,7 @@ "Does not raise event for initial document delete": { "describeName": "Listens:", "itName": "Does not raise event for initial document delete", - "tags": [""], + "tags": [], "config": { "useGarbageCollection": true }, @@ -603,8 +626,12 @@ "removedTargets": [ 2 ] - }, - "watchSnapshot": 1000 + } + }, + { + "watchSnapshot": { + "version": 1000 + } }, { "watchCurrent": [ @@ -612,8 +639,12 @@ 2 ], "resume-token-2000" - ], - "watchSnapshot": 2000, + ] + }, + { + "watchSnapshot": { + "version": 2000 + }, "expect": [ { "query": { @@ -833,8 +864,12 @@ 4 ], "resume-token-2000" - ], - "watchSnapshot": 2000, + ] + }, + { + "watchSnapshot": { + "version": 2000 + }, "expect": [ { "query": { @@ -916,8 +951,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -954,8 +993,12 @@ "targets": [ 2 ] + } + }, + { + "watchSnapshot": { + "version": 2000 }, - "watchSnapshot": 2000, "expect": [ { "query": { @@ -1068,8 +1111,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000 + ] + }, + { + "watchSnapshot": { + "version": 1000 + } }, { "watchEntity": { @@ -1085,8 +1132,12 @@ "targets": [ 2 ] + } + }, + { + "watchSnapshot": { + "version": 2000 }, - "watchSnapshot": 2000, "expect": [ { "query": { @@ -1159,8 +1210,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -1197,8 +1252,12 @@ "targets": [ 2 ] + } + }, + { + "watchSnapshot": { + "version": 2000 }, - "watchSnapshot": 2000, "expect": [ { "query": { @@ -1298,8 +1357,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000 + ] + }, + { + "watchSnapshot": { + "version": 1000 + } }, { "watchEntity": { @@ -1315,8 +1378,12 @@ "targets": [ 2 ] + } + }, + { + "watchSnapshot": { + "version": 2000 }, - "watchSnapshot": 2000, "expect": [ { "query": { @@ -1402,8 +1469,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -1531,8 +1602,12 @@ 4 ], "resume-token-4000" - ], - "watchSnapshot": 4000, + ] + }, + { + "watchSnapshot": { + "version": 4000 + }, "expect": [ { "query": { @@ -1638,8 +1713,12 @@ 2 ], "resume-token-5000" - ], - "watchSnapshot": 5000, + ] + }, + { + "watchSnapshot": { + "version": 5000 + }, "expect": [ { "query": { @@ -1748,8 +1827,12 @@ 4 ], "resume-token-6000" - ], - "watchSnapshot": 6000, + ] + }, + { + "watchSnapshot": { + "version": 6000 + }, "expect": [ { "query": { @@ -1823,8 +1906,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -1909,8 +1996,12 @@ 2 ], "resume-token-2000" - ], - "watchSnapshot": 2000, + ] + }, + { + "watchSnapshot": { + "version": 2000 + }, "expect": [ { "query": { @@ -1999,8 +2090,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -2167,8 +2262,12 @@ 4 ], "resume-token-2000" - ], - "watchSnapshot": 2000, + ] + }, + { + "watchSnapshot": { + "version": 2000 + }, "expect": [ { "query": { @@ -2313,8 +2412,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -2425,8 +2528,12 @@ 2 ], "resume-token-2000" - ], - "watchSnapshot": 2000, + ] + }, + { + "watchSnapshot": { + "version": 2000 + }, "expect": [ { "query": { @@ -2508,8 +2615,12 @@ 2 ], "resume-token-1000" - ], - "watchSnapshot": 1000, + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, "expect": [ { "query": { @@ -2559,8 +2670,12 @@ "targets": [ 2 ] - }, - "watchSnapshot": 2000 + } + }, + { + "watchSnapshot": { + "version": 2000 + } }, { "watchRemove": { @@ -2663,8 +2778,12 @@ "targets": [ 2 ] + } + }, + { + "watchSnapshot": { + "version": 1000 }, - "watchSnapshot": 1000, "expect": [ { "query": { @@ -2693,8 +2812,12 @@ 2 ], "resume-token-2000" - ], - "watchSnapshot": 2000, + ] + }, + { + "watchSnapshot": { + "version": 2000 + }, "expect": [ { "query": { @@ -2765,5 +2888,229 @@ ] } ] + }, + "Persists resume token sent with target": { + "describeName": "Listens:", + "itName": "Persists resume token sent with target", + "tags": [ + "exclusive" + ], + "config": { + "useGarbageCollection": false + }, + "steps": [ + { + "userListen": [ + 2, + { + "path": "collection", + "filters": [], + "orderBys": [] + } + ], + "stateExpect": { + "activeTargets": { + "2": { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "resumeToken": "" + } + } + } + }, + { + "watchAck": [ + 2 + ] + }, + { + "watchEntity": { + "docs": [], + "targets": [ + 2 + ] + } + }, + { + "watchCurrent": [ + [ + 2 + ], + "resume-token-1000" + ] + }, + { + "watchSnapshot": { + "version": 1000 + }, + "expect": [ + { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "errorCode": 0, + "fromCache": false, + "hasPendingWrites": false + } + ] + }, + { + "watchEntity": { + "docs": [ + [ + "collection/a", + 2000, + { + "key": "a" + } + ] + ], + "targets": [ + 2 + ] + } + }, + { + "watchSnapshot": { + "version": 2000, + "targetIds": [ + 2 + ], + "resumeToken": "resume-token-2000" + } + }, + { + "watchSnapshot": { + "version": 2000 + }, + "expect": [ + { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "added": [ + [ + "collection/a", + 2000, + { + "key": "a" + } + ] + ], + "errorCode": 0, + "fromCache": false, + "hasPendingWrites": false + } + ] + }, + { + "userUnlisten": [ + 2, + { + "path": "collection", + "filters": [], + "orderBys": [] + } + ], + "stateExpect": { + "activeTargets": {} + } + }, + { + "watchRemove": { + "targetIds": [ + 2 + ] + } + }, + { + "userListen": [ + 2, + { + "path": "collection", + "filters": [], + "orderBys": [] + } + ], + "stateExpect": { + "activeTargets": { + "2": { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "resumeToken": "resume-token-2000" + } + } + }, + "expect": [ + { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "added": [ + [ + "collection/a", + 2000, + { + "key": "a" + } + ] + ], + "errorCode": 0, + "fromCache": true, + "hasPendingWrites": false + } + ] + }, + { + "watchAck": [ + 2 + ] + }, + { + "watchEntity": { + "docs": [], + "targets": [ + 2 + ] + } + }, + { + "watchCurrent": [ + [ + 2 + ], + "resume-token-3000" + ] + }, + { + "watchSnapshot": { + "version": 3000 + }, + "expect": [ + { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "errorCode": 0, + "fromCache": false, + "hasPendingWrites": false + } + ] + } + ] } } -- cgit v1.2.3