diff options
author | Michael Lehenbauer <mikelehen@gmail.com> | 2018-03-12 11:53:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-12 11:53:26 -0700 |
commit | f122cf7ce802972bd2fea45acac3deae2affcafa (patch) | |
tree | 58e996c86a48528fc5c96c6a535295adcfac723e /Firestore/Example/Tests | |
parent | 7522314812b934884f8877d36a66a4686f424a8f (diff) |
Fix MutationQueue issue resulting in re-sending acknowledged writes. (#909)
Port of: https://github.com/firebase/firebase-js-sdk/pull/559
Should address #772 once released.
getNextMutationBatchAfterBatchId() was not respecting
highestAcknowledgedBatchId and therefore we were resending writes after the
network was disabled / re-enabled.
Diffstat (limited to 'Firestore/Example/Tests')
-rw-r--r-- | Firestore/Example/Tests/Local/FSTMutationQueueTests.mm | 16 | ||||
-rw-r--r-- | Firestore/Example/Tests/SpecTests/json/write_spec_test.json | 192 |
2 files changed, 208 insertions, 0 deletions
diff --git a/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm b/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm index 7d305d0..f5294d5 100644 --- a/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm +++ b/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm @@ -217,6 +217,22 @@ NS_ASSUME_NONNULL_BEGIN XCTAssertNil(notFound); } +- (void)testNextMutationBatchAfterBatchIDSkipsAcknowledgedBatches { + if ([self isTestBaseClass]) return; + + NSMutableArray<FSTMutationBatch *> *batches = [self createBatches:3]; + XCTAssertEqualObjects([self.mutationQueue nextMutationBatchAfterBatchID:kFSTBatchIDUnknown], + batches[0]); + + [self acknowledgeBatch:batches[0]]; + XCTAssertEqualObjects([self.mutationQueue nextMutationBatchAfterBatchID:kFSTBatchIDUnknown], + batches[1]); + XCTAssertEqualObjects([self.mutationQueue nextMutationBatchAfterBatchID:batches[0].batchID], + batches[1]); + XCTAssertEqualObjects([self.mutationQueue nextMutationBatchAfterBatchID:batches[1].batchID], + batches[2]); +} + - (void)testAllMutationBatchesThroughBatchID { if ([self isTestBaseClass]) return; diff --git a/Firestore/Example/Tests/SpecTests/json/write_spec_test.json b/Firestore/Example/Tests/SpecTests/json/write_spec_test.json index 8e3f5d5..d4d1e7c 100644 --- a/Firestore/Example/Tests/SpecTests/json/write_spec_test.json +++ b/Firestore/Example/Tests/SpecTests/json/write_spec_test.json @@ -3407,6 +3407,198 @@ } ] }, + "Held writes are not re-sent after disable/enable network.": { + "describeName": "Writes:", + "itName": "Held writes are not re-sent after disable/enable network.", + "tags": [], + "config": { + "useGarbageCollection": true + }, + "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-500" + ], + "watchSnapshot": 500, + "expect": [ + { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "errorCode": 0, + "fromCache": false, + "hasPendingWrites": false + } + ] + }, + { + "userSet": [ + "collection/a", + { + "v": 1 + } + ], + "expect": [ + { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "added": [ + [ + "collection/a", + 0, + { + "v": 1 + }, + "local" + ] + ], + "errorCode": 0, + "fromCache": false, + "hasPendingWrites": true + } + ] + }, + { + "writeAck": { + "version": 1000, + "expectUserCallback": true + }, + "stateExpect": { + "writeStreamRequestCount": 2 + } + }, + { + "enableNetwork": false, + "stateExpect": { + "activeTargets": {}, + "limboDocs": [], + "writeStreamRequestCount": 3 + }, + "expect": [ + { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "errorCode": 0, + "fromCache": true, + "hasPendingWrites": true + } + ] + }, + { + "enableNetwork": true, + "stateExpect": { + "activeTargets": { + "2": { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "resumeToken": "resume-token-500" + } + }, + "writeStreamRequestCount": 3 + } + }, + { + "watchAck": [ + 2 + ] + }, + { + "watchEntity": { + "docs": [ + [ + "collection/a", + 1000, + { + "v": 1 + } + ] + ], + "targets": [ + 2 + ] + } + }, + { + "watchCurrent": [ + [ + 2 + ], + "resume-token-2000" + ], + "watchSnapshot": 2000, + "expect": [ + { + "query": { + "path": "collection", + "filters": [], + "orderBys": [] + }, + "metadata": [ + [ + "collection/a", + 1000, + { + "v": 1 + } + ] + ], + "errorCode": 0, + "fromCache": false, + "hasPendingWrites": false + } + ] + } + ] + }, "Held writes are released when there are no queries left.": { "describeName": "Writes:", "itName": "Held writes are released when there are no queries left.", |