3131#include " Firestore/core/src/firebase/firestore/auth/user.h"
3232#include " Firestore/core/src/firebase/firestore/model/document_key.h"
3333#include " Firestore/core/src/firebase/firestore/model/document_key_set.h"
34+ #include " Firestore/core/src/firebase/firestore/model/mutation_batch.h"
3435#include " Firestore/core/test/firebase/firestore/testutil/testutil.h"
3536
3637namespace testutil = firebase::firestore::testutil;
3738using firebase::firestore::auth::User;
3839using firebase::firestore::model::DocumentKey;
3940using firebase::firestore::model::DocumentKeySet;
41+ using firebase::firestore::model::kBatchIdUnknown ;
4042using firebase::firestore::testutil::Key;
4143
4244NS_ASSUME_NONNULL_BEGIN
@@ -83,32 +85,30 @@ - (void)testCountBatches {
8385- (void )testAcknowledgeBatchID {
8486 if ([self isTestBaseClass ]) return ;
8587
86- // Initial state of an empty queue
87- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], kFSTBatchIDUnknown );
88-
89- // Adding mutation batches should not change the highest acked batchID.
9088 self.persistence .run (" testAcknowledgeBatchID" , [&]() {
89+ XCTAssertEqual ([self batchCount ], 0 );
90+
9191 FSTMutationBatch *batch1 = [self addMutationBatch ];
9292 FSTMutationBatch *batch2 = [self addMutationBatch ];
9393 FSTMutationBatch *batch3 = [self addMutationBatch ];
94- XCTAssertGreaterThan (batch1.batchID , kFSTBatchIDUnknown );
94+ XCTAssertGreaterThan (batch1.batchID , kBatchIdUnknown );
9595 XCTAssertGreaterThan (batch2.batchID , batch1.batchID );
9696 XCTAssertGreaterThan (batch3.batchID , batch2.batchID );
9797
98- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], kFSTBatchIDUnknown );
98+ XCTAssertEqual ([self batchCount ], 3 );
9999
100100 [self .mutationQueue acknowledgeBatch: batch1 streamToken: nil ];
101101 [self .mutationQueue removeMutationBatch: batch1];
102+ XCTAssertEqual ([self batchCount ], 2 );
102103
103104 [self .mutationQueue acknowledgeBatch: batch2 streamToken: nil ];
104- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], batch2. batchID );
105+ XCTAssertEqual ([self batchCount ], 2 );
105106
106107 [self .mutationQueue removeMutationBatch: batch2];
107- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], batch2. batchID );
108+ XCTAssertEqual ([self batchCount ], 1 );
108109
109- // Batch 3 never acknowledged.
110110 [self .mutationQueue removeMutationBatch: batch3];
111- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], batch2. batchID );
111+ XCTAssertEqual ([self batchCount ], 0 );
112112 });
113113}
114114
@@ -122,7 +122,6 @@ - (void)testAcknowledgeThenRemove {
122122 [self .mutationQueue removeMutationBatch: batch1];
123123
124124 XCTAssertEqual ([self batchCount ], 0 );
125- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], batch1.batchID );
126125 });
127126}
128127
@@ -186,28 +185,6 @@ - (void)testNextMutationBatchAfterBatchID {
186185 });
187186}
188187
189- - (void )testNextMutationBatchAfterBatchIDSkipsAcknowledgedBatches {
190- if ([self isTestBaseClass ]) return ;
191-
192- NSMutableArray <FSTMutationBatch *> *batches = self.persistence .run (
193- " testNextMutationBatchAfterBatchIDSkipsAcknowledgedBatches newBatches" ,
194- [&]() -> NSMutableArray <FSTMutationBatch *> * {
195- NSMutableArray <FSTMutationBatch *> *newBatches = [self createBatches: 3 ];
196- XCTAssertEqualObjects ([self .mutationQueue nextMutationBatchAfterBatchID: kFSTBatchIDUnknown ],
197- newBatches[0 ]);
198- return newBatches;
199- });
200- self.persistence .run (" testNextMutationBatchAfterBatchIDSkipsAcknowledgedBatches" , [&]() {
201- [self .mutationQueue acknowledgeBatch: batches[0 ] streamToken: nil ];
202- XCTAssertEqualObjects ([self .mutationQueue nextMutationBatchAfterBatchID: kFSTBatchIDUnknown ],
203- batches[1 ]);
204- XCTAssertEqualObjects ([self .mutationQueue nextMutationBatchAfterBatchID: batches[0 ].batchID],
205- batches[1 ]);
206- XCTAssertEqualObjects ([self .mutationQueue nextMutationBatchAfterBatchID: batches[1 ].batchID],
207- batches[2 ]);
208- });
209- }
210-
211188- (void )testAllMutationBatchesAffectingDocumentKey {
212189 if ([self isTestBaseClass ]) return ;
213190
@@ -406,7 +383,6 @@ - (void)testStreamToken {
406383 XCTAssertEqualObjects ([self .mutationQueue lastStreamToken ], streamToken1);
407384
408385 [self .mutationQueue acknowledgeBatch: batch1 streamToken: streamToken2];
409- XCTAssertEqual (self.mutationQueue .highestAcknowledgedBatchID , batch1.batchID );
410386 XCTAssertEqualObjects ([self .mutationQueue lastStreamToken ], streamToken2);
411387 });
412388}
0 commit comments