Skip to content

Commit 656b9c0

Browse files
Remove unused test helpers (#4473)
1 parent f2e0a5e commit 656b9c0

File tree

2 files changed

+0
-201
lines changed

2 files changed

+0
-201
lines changed

Firestore/Example/Tests/Util/FSTHelpers.h

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ namespace model = firebase::firestore::model;
6565

6666
NS_ASSUME_NONNULL_BEGIN
6767

68-
#define FSTAssertIsKindOfClass(value, classType) \
69-
do { \
70-
XCTAssertEqualObjects([value class], [classType class]); \
71-
} while (0);
72-
7368
/**
7469
* Takes an array of "equality group" arrays and asserts that the compare: selector returns the
7570
* same as compare: on the indexes of the "equality groups" (NSOrderedSame for items in the same
@@ -94,31 +89,6 @@ NS_ASSUME_NONNULL_BEGIN
9489
} \
9590
} while (0)
9691

97-
/**
98-
* Takes an array of "equality group" arrays and asserts that the isEqual: selector returns TRUE
99-
* if-and-only-if items are in the same group.
100-
*
101-
* Additionally checks that the hash: selector returns the same value for items in the same group.
102-
*/
103-
#define FSTAssertEqualityGroups(values) \
104-
do { \
105-
for (NSUInteger i = 0; i < [values count]; i++) { \
106-
for (id left in values[i]) { \
107-
for (NSUInteger j = 0; j < [values count]; j++) { \
108-
for (id right in values[j]) { \
109-
if (i == j) { \
110-
XCTAssertEqualObjects(left, right); \
111-
XCTAssertEqual([left hash], [right hash], @"comparing hash of %@ with hash of %@", \
112-
left, right); \
113-
} else { \
114-
XCTAssertNotEqualObjects(left, right); \
115-
} \
116-
} \
117-
} \
118-
} \
119-
} \
120-
} while (0)
121-
12292
static NSString *kExceptionPrefix = @"FIRESTORE INTERNAL ASSERTION FAILED: ";
12393

12494
// Remove possible exception-prefix.
@@ -144,18 +114,6 @@ inline NSString *FSTRemoveExceptionPrefix(NSString *exception) {
144114
XCTAssertTrue(didThrow, ##__VA_ARGS__); \
145115
} while (0)
146116

147-
// Helper to compare vectors containing Objective-C objects.
148-
#define FSTAssertEqualVectors(v1, v2) \
149-
do { \
150-
XCTAssertEqual(v1.size(), v2.size(), @"Vector length mismatch"); \
151-
for (size_t i = 0; i < v1.size(); i++) { \
152-
XCTAssertEqualObjects(v1[i], v2[i]); \
153-
} \
154-
} while (0)
155-
156-
/** Creates a new FIRTimestamp from components. Note that year, month, and day are all one-based. */
157-
FIRTimestamp *FSTTestTimestamp(int year, int month, int day, int hour, int minute, int second);
158-
159117
/** Creates a new NSDate from components. Note that year, month, and day are all one-based. */
160118
NSDate *FSTTestDate(int year, int month, int day, int hour, int minute, int second);
161119

@@ -196,12 +154,6 @@ typedef int64_t FSTTestSnapshotVersion;
196154
*/
197155
FSTDocumentKeyReference *FSTTestRef(std::string projectID, std::string databaseID, NSString *path);
198156

199-
/** Computes changes to the view with the docs and then applies them and returns the snapshot. */
200-
absl::optional<core::ViewSnapshot> FSTTestApplyChanges(
201-
core::View *view,
202-
const std::vector<model::MaybeDocument> &docs,
203-
const absl::optional<firebase::firestore::remote::TargetChange> &targetChange);
204-
205157
/** Creates a set mutation for the document key at the given path. */
206158
model::SetMutation FSTTestSetMutation(NSString *path, NSDictionary<NSString *, id> *values);
207159

@@ -222,46 +174,4 @@ model::TransformMutation FSTTestTransformMutation(NSString *path,
222174
/** Creates a delete mutation for the document key at the given path. */
223175
model::DeleteMutation FSTTestDeleteMutation(NSString *path);
224176

225-
/** Converts a list of documents to a sorted map. */
226-
firebase::firestore::model::MaybeDocumentMap FSTTestDocUpdates(
227-
const std::vector<model::MaybeDocument> &docs);
228-
229-
/** Creates a remote event that inserts a new document. */
230-
firebase::firestore::remote::RemoteEvent FSTTestAddedRemoteEvent(
231-
const model::MaybeDocument &doc,
232-
const std::vector<firebase::firestore::model::TargetId> &addedToTargets);
233-
234-
/** Creates a remote event that inserts a list of documents. */
235-
firebase::firestore::remote::RemoteEvent FSTTestAddedRemoteEvent(
236-
const std::vector<model::MaybeDocument> &doc,
237-
const std::vector<firebase::firestore::model::TargetId> &addedToTargets);
238-
239-
/** Creates a remote event with changes to a document. */
240-
firebase::firestore::remote::RemoteEvent FSTTestUpdateRemoteEvent(
241-
const model::MaybeDocument &doc,
242-
const std::vector<firebase::firestore::model::TargetId> &updatedInTargets,
243-
const std::vector<firebase::firestore::model::TargetId> &removedFromTargets);
244-
245-
/** Creates a remote event with changes to a document. Allows for identifying limbo targets */
246-
firebase::firestore::remote::RemoteEvent FSTTestUpdateRemoteEventWithLimboTargets(
247-
const model::MaybeDocument &doc,
248-
const std::vector<firebase::firestore::model::TargetId> &updatedInTargets,
249-
const std::vector<firebase::firestore::model::TargetId> &removedFromTargets,
250-
const std::vector<firebase::firestore::model::TargetId> &limboTargets);
251-
252-
/** Creates a test view changes. */
253-
local::LocalViewChanges TestViewChanges(firebase::firestore::model::TargetId targetID,
254-
NSArray<NSString *> *addedKeys,
255-
NSArray<NSString *> *removedKeys);
256-
257-
/** Creates a test target change that acks all 'docs' and marks the target as CURRENT */
258-
firebase::firestore::remote::TargetChange FSTTestTargetChangeAckDocuments(
259-
firebase::firestore::model::DocumentKeySet docs);
260-
261-
/** Creates a test target change that marks the target as CURRENT */
262-
firebase::firestore::remote::TargetChange FSTTestTargetChangeMarkCurrent();
263-
264-
/** Creates a resume token to match the given snapshot version. */
265-
NSData *_Nullable FSTTestResumeTokenFromSnapshotVersion(FSTTestSnapshotVersion watchSnapshot);
266-
267177
NS_ASSUME_NONNULL_END

Firestore/Example/Tests/Util/FSTHelpers.mm

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,12 @@
9999
using firebase::firestore::remote::RemoteEvent;
100100
using firebase::firestore::remote::TargetChange;
101101
using firebase::firestore::remote::WatchChangeAggregator;
102-
using firebase::firestore::testutil::OrderBy;
103-
using firebase::firestore::testutil::Query;
104102

105103
NS_ASSUME_NONNULL_BEGIN
106104

107105
/** A string sentinel that can be used with FSTTestPatchMutation() to mark a field for deletion. */
108106
static NSString *const kDeleteSentinel = @"<DELETE>";
109107

110-
FIRTimestamp *FSTTestTimestamp(int year, int month, int day, int hour, int minute, int second) {
111-
NSDate *date = FSTTestDate(year, month, day, hour, minute, second);
112-
return [FIRTimestamp timestampWithDate:date];
113-
}
114-
115108
NSDate *FSTTestDate(int year, int month, int day, int hour, int minute, int second) {
116109
NSDateComponents *comps = FSTTestDateComponents(year, month, day, hour, minute, second);
117110
return [[NSCalendar currentCalendar] dateFromComponents:comps];
@@ -224,108 +217,4 @@ DeleteMutation FSTTestDeleteMutation(NSString *path) {
224217
return DeleteMutation(FSTTestDocKey(path), Precondition::None());
225218
}
226219

227-
MaybeDocumentMap FSTTestDocUpdates(const std::vector<MaybeDocument> &docs) {
228-
MaybeDocumentMap updates;
229-
for (const MaybeDocument &doc : docs) {
230-
updates = updates.insert(doc.key(), doc);
231-
}
232-
return updates;
233-
}
234-
235-
absl::optional<ViewSnapshot> FSTTestApplyChanges(View *view,
236-
const std::vector<MaybeDocument> &docs,
237-
const absl::optional<TargetChange> &targetChange) {
238-
ViewChange change =
239-
view->ApplyChanges(view->ComputeDocumentChanges(FSTTestDocUpdates(docs)), targetChange);
240-
return change.snapshot();
241-
}
242-
243-
RemoteEvent FSTTestAddedRemoteEvent(const MaybeDocument &doc,
244-
const std::vector<TargetId> &addedToTargets) {
245-
std::vector<MaybeDocument> docs{doc};
246-
return FSTTestAddedRemoteEvent(docs, addedToTargets);
247-
}
248-
249-
RemoteEvent FSTTestAddedRemoteEvent(const std::vector<MaybeDocument> &docs,
250-
const std::vector<TargetId> &addedToTargets) {
251-
HARD_ASSERT(!docs.empty(), "Cannot pass empty docs array");
252-
253-
const ResourcePath &collectionPath = docs[0].key().path().PopLast();
254-
auto metadataProvider =
255-
FakeTargetMetadataProvider::CreateEmptyResultProvider(collectionPath, addedToTargets);
256-
WatchChangeAggregator aggregator{&metadataProvider};
257-
for (const MaybeDocument &doc : docs) {
258-
HARD_ASSERT(!doc.is_document() || !Document(doc).has_local_mutations(),
259-
"Docs from remote updates shouldn't have local changes.");
260-
DocumentWatchChange change{addedToTargets, {}, doc.key(), doc};
261-
aggregator.HandleDocumentChange(change);
262-
}
263-
return aggregator.CreateRemoteEvent(docs[0].version());
264-
}
265-
266-
TargetChange FSTTestTargetChangeMarkCurrent() {
267-
return {ByteString(),
268-
/*current=*/true,
269-
/*added_documents=*/DocumentKeySet{},
270-
/*modified_documents=*/DocumentKeySet{},
271-
/*removed_documents=*/DocumentKeySet{}};
272-
}
273-
274-
TargetChange FSTTestTargetChangeAckDocuments(DocumentKeySet docs) {
275-
return {ByteString(),
276-
/*current=*/true,
277-
/*added_documents*/ std::move(docs),
278-
/*modified_documents*/ DocumentKeySet{},
279-
/*removed_documents*/ DocumentKeySet{}};
280-
}
281-
282-
RemoteEvent FSTTestUpdateRemoteEventWithLimboTargets(
283-
const MaybeDocument &doc,
284-
const std::vector<TargetId> &updatedInTargets,
285-
const std::vector<TargetId> &removedFromTargets,
286-
const std::vector<TargetId> &limboTargets) {
287-
HARD_ASSERT(!doc.is_document() || !Document(doc).has_local_mutations(),
288-
"Docs from remote updates shouldn't have local changes.");
289-
DocumentWatchChange change{updatedInTargets, removedFromTargets, doc.key(), doc};
290-
291-
std::vector<TargetId> listens = updatedInTargets;
292-
listens.insert(listens.end(), removedFromTargets.begin(), removedFromTargets.end());
293-
294-
auto metadataProvider =
295-
FakeTargetMetadataProvider::CreateSingleResultProvider(doc.key(), listens, limboTargets);
296-
WatchChangeAggregator aggregator{&metadataProvider};
297-
aggregator.HandleDocumentChange(change);
298-
return aggregator.CreateRemoteEvent(doc.version());
299-
}
300-
301-
RemoteEvent FSTTestUpdateRemoteEvent(const MaybeDocument &doc,
302-
const std::vector<TargetId> &updatedInTargets,
303-
const std::vector<TargetId> &removedFromTargets) {
304-
return FSTTestUpdateRemoteEventWithLimboTargets(doc, updatedInTargets, removedFromTargets, {});
305-
}
306-
307-
/** Creates a resume token to match the given snapshot version. */
308-
NSData *_Nullable FSTTestResumeTokenFromSnapshotVersion(FSTTestSnapshotVersion snapshotVersion) {
309-
if (snapshotVersion == 0) {
310-
return nil;
311-
}
312-
313-
NSString *snapshotString = [NSString stringWithFormat:@"snapshot-%" PRId64, snapshotVersion];
314-
return [snapshotString dataUsingEncoding:NSUTF8StringEncoding];
315-
}
316-
317-
LocalViewChanges TestViewChanges(TargetId targetID,
318-
NSArray<NSString *> *addedKeys,
319-
NSArray<NSString *> *removedKeys) {
320-
DocumentKeySet added;
321-
for (NSString *keyPath in addedKeys) {
322-
added = added.insert(testutil::Key(util::MakeString(keyPath)));
323-
}
324-
DocumentKeySet removed;
325-
for (NSString *keyPath in removedKeys) {
326-
removed = removed.insert(testutil::Key(util::MakeString(keyPath)));
327-
}
328-
return LocalViewChanges(targetID, std::move(added), std::move(removed));
329-
}
330-
331220
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)