31
31
#include " Firestore/core/src/firebase/firestore/auth/user.h"
32
32
#include " Firestore/core/src/firebase/firestore/model/document_key.h"
33
33
#include " Firestore/core/src/firebase/firestore/model/document_key_set.h"
34
+ #include " Firestore/core/src/firebase/firestore/model/mutation_batch.h"
34
35
#include " Firestore/core/test/firebase/firestore/testutil/testutil.h"
35
36
36
37
namespace testutil = firebase::firestore::testutil;
37
38
using firebase::firestore::auth::User;
38
39
using firebase::firestore::model::DocumentKey;
39
40
using firebase::firestore::model::DocumentKeySet;
41
+ using firebase::firestore::model::kBatchIdUnknown ;
40
42
using firebase::firestore::testutil::Key;
41
43
42
44
NS_ASSUME_NONNULL_BEGIN
@@ -83,32 +85,30 @@ - (void)testCountBatches {
83
85
- (void )testAcknowledgeBatchID {
84
86
if ([self isTestBaseClass ]) return ;
85
87
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.
90
88
self.persistence .run (" testAcknowledgeBatchID" , [&]() {
89
+ XCTAssertEqual ([self batchCount ], 0 );
90
+
91
91
FSTMutationBatch *batch1 = [self addMutationBatch ];
92
92
FSTMutationBatch *batch2 = [self addMutationBatch ];
93
93
FSTMutationBatch *batch3 = [self addMutationBatch ];
94
- XCTAssertGreaterThan (batch1.batchID , kFSTBatchIDUnknown );
94
+ XCTAssertGreaterThan (batch1.batchID , kBatchIdUnknown );
95
95
XCTAssertGreaterThan (batch2.batchID , batch1.batchID );
96
96
XCTAssertGreaterThan (batch3.batchID , batch2.batchID );
97
97
98
- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], kFSTBatchIDUnknown );
98
+ XCTAssertEqual ([self batchCount ], 3 );
99
99
100
100
[self .mutationQueue acknowledgeBatch: batch1 streamToken: nil ];
101
101
[self .mutationQueue removeMutationBatch: batch1];
102
+ XCTAssertEqual ([self batchCount ], 2 );
102
103
103
104
[self .mutationQueue acknowledgeBatch: batch2 streamToken: nil ];
104
- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], batch2. batchID );
105
+ XCTAssertEqual ([self batchCount ], 2 );
105
106
106
107
[self .mutationQueue removeMutationBatch: batch2];
107
- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], batch2. batchID );
108
+ XCTAssertEqual ([self batchCount ], 1 );
108
109
109
- // Batch 3 never acknowledged.
110
110
[self .mutationQueue removeMutationBatch: batch3];
111
- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], batch2. batchID );
111
+ XCTAssertEqual ([self batchCount ], 0 );
112
112
});
113
113
}
114
114
@@ -122,7 +122,6 @@ - (void)testAcknowledgeThenRemove {
122
122
[self .mutationQueue removeMutationBatch: batch1];
123
123
124
124
XCTAssertEqual ([self batchCount ], 0 );
125
- XCTAssertEqual ([self .mutationQueue highestAcknowledgedBatchID ], batch1.batchID );
126
125
});
127
126
}
128
127
@@ -186,28 +185,6 @@ - (void)testNextMutationBatchAfterBatchID {
186
185
});
187
186
}
188
187
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
-
211
188
- (void )testAllMutationBatchesAffectingDocumentKey {
212
189
if ([self isTestBaseClass ]) return ;
213
190
@@ -406,7 +383,6 @@ - (void)testStreamToken {
406
383
XCTAssertEqualObjects ([self .mutationQueue lastStreamToken ], streamToken1);
407
384
408
385
[self .mutationQueue acknowledgeBatch: batch1 streamToken: streamToken2];
409
- XCTAssertEqual (self.mutationQueue .highestAcknowledgedBatchID , batch1.batchID );
410
386
XCTAssertEqualObjects ([self .mutationQueue lastStreamToken ], streamToken2);
411
387
});
412
388
}
0 commit comments