Skip to content

Commit d7b9e60

Browse files
committed
FIRSource -> FIRGetSource
1 parent 3abd449 commit d7b9e60

File tree

8 files changed

+85
-79
lines changed

8 files changed

+85
-79
lines changed

Firestore/Example/SwiftBuildTest/main.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ func readDocument(at docRef: DocumentReference) {
228228
func readDocumentWithOptions(at docRef: DocumentReference) {
229229
docRef.getDocument(options:GetOptions.defaultOptions()) { document, error in
230230
}
231-
docRef.getDocument(options:GetOptions.init(source:Source.default)) { document, error in
231+
docRef.getDocument(options:GetOptions.init(source:GetSource.default)) { document, error in
232232
}
233-
docRef.getDocument(options:GetOptions.init(source:Source.server)) { document, error in
233+
docRef.getDocument(options:GetOptions.init(source:GetSource.server)) { document, error in
234234
}
235-
docRef.getDocument(options:GetOptions.init(source:Source.cache)) { document, error in
235+
docRef.getDocument(options:GetOptions.init(source:GetSource.cache)) { document, error in
236236
}
237237
}
238238

@@ -249,11 +249,11 @@ func readDocuments(matching query: Query) {
249249
func readDocumentsWithOptions(matching query: Query) {
250250
query.getDocuments(options:GetOptions.defaultOptions()) { querySnapshot, error in
251251
}
252-
query.getDocuments(options:GetOptions.init(source:Source.default)) { querySnapshot, error in
252+
query.getDocuments(options:GetOptions.init(source:GetSource.default)) { querySnapshot, error in
253253
}
254-
query.getDocuments(options:GetOptions.init(source:Source.server)) { querySnapshot, error in
254+
query.getDocuments(options:GetOptions.init(source:GetSource.server)) { querySnapshot, error in
255255
}
256-
query.getDocuments(options:GetOptions.init(source:Source.cache)) { querySnapshot, error in
256+
query.getDocuments(options:GetOptions.init(source:GetSource.cache)) { querySnapshot, error in
257257
}
258258
}
259259

Firestore/Example/Tests/Integration/API/FIRGetOptionsTests.m

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ - (void)testGetDocumentWhileOnlineCacheOnly {
145145
// get doc and ensure that it exists, *is* from the cache, and matches
146146
// the initialData.
147147
FIRDocumentSnapshot *result =
148-
[self readDocumentForRef:doc options:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]];
148+
[self readDocumentForRef:doc
149+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]];
149150
XCTAssertTrue(result.exists);
150151
XCTAssertTrue(result.metadata.fromCache);
151152
XCTAssertFalse(result.metadata.hasPendingWrites);
@@ -167,7 +168,7 @@ - (void)testGetCollectionWhileOnlineCacheOnly {
167168
// initialDocs.
168169
FIRQuerySnapshot *result =
169170
[self readDocumentSetForRef:col
170-
options:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]];
171+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]];
171172
XCTAssertTrue(result.metadata.fromCache);
172173
XCTAssertFalse(result.metadata.hasPendingWrites);
173174
XCTAssertEqualObjects(FIRQuerySnapshotGetData(result), (@[
@@ -204,7 +205,8 @@ - (void)testGetDocumentWhileOfflineCacheOnly {
204205
// get doc and ensure it exists, *is* from the cache, and matches the
205206
// newData.
206207
FIRDocumentSnapshot *result =
207-
[self readDocumentForRef:doc options:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]];
208+
[self readDocumentForRef:doc
209+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]];
208210
XCTAssertTrue(result.exists);
209211
XCTAssertTrue(result.metadata.fromCache);
210212
XCTAssertTrue(result.metadata.hasPendingWrites);
@@ -236,7 +238,7 @@ - (void)testGetCollectionWhileOfflineCacheOnly {
236238
// data.
237239
FIRQuerySnapshot *result =
238240
[self readDocumentSetForRef:col
239-
options:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]];
241+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]];
240242
XCTAssertTrue(result.metadata.fromCache);
241243
XCTAssertTrue(result.metadata.hasPendingWrites);
242244
XCTAssertEqualObjects(FIRQuerySnapshotGetData(result), (@[
@@ -262,7 +264,8 @@ - (void)testGetDocumentWhileOnlineServerOnly {
262264
// get doc and ensure that it exists, is *not* from the cache, and matches
263265
// the initialData.
264266
FIRDocumentSnapshot *result =
265-
[self readDocumentForRef:doc options:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]];
267+
[self readDocumentForRef:doc
268+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]];
266269
XCTAssertTrue(result.exists);
267270
XCTAssertFalse(result.metadata.fromCache);
268271
XCTAssertFalse(result.metadata.hasPendingWrites);
@@ -284,7 +287,7 @@ - (void)testGetCollectionWhileOnlineServerOnly {
284287
// initialData.
285288
FIRQuerySnapshot *result =
286289
[self readDocumentSetForRef:col
287-
options:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]];
290+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]];
288291
XCTAssertFalse(result.metadata.fromCache);
289292
XCTAssertFalse(result.metadata.hasPendingWrites);
290293
XCTAssertEqualObjects(FIRQuerySnapshotGetData(result), (@[
@@ -311,7 +314,7 @@ - (void)testGetDocumentWhileOfflineServerOnly {
311314

312315
// attempt to get doc and ensure it cannot be retreived
313316
XCTestExpectation *failedGetDocCompletion = [self expectationWithDescription:@"failedGetDoc"];
314-
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]
317+
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]
315318
completion:^(FIRDocumentSnapshot *snapshot, NSError *error) {
316319
XCTAssertNotNil(error);
317320
XCTAssertEqualObjects(error.domain, FIRFirestoreErrorDomain);
@@ -337,7 +340,7 @@ - (void)testGetCollectionWhileOfflineServerOnly {
337340

338341
// attempt to get docs and ensure they cannot be retreived
339342
XCTestExpectation *failedGetDocsCompletion = [self expectationWithDescription:@"failedGetDocs"];
340-
[col getDocumentsWithOptions:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]
343+
[col getDocumentsWithOptions:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]
341344
completion:^(FIRQuerySnapshot *snapshot, NSError *error) {
342345
XCTAssertNotNil(error);
343346
XCTAssertEqualObjects(error.domain, FIRFirestoreErrorDomain);
@@ -377,23 +380,24 @@ - (void)testGetDocumentWhileOfflineWithDifferentGetOptions {
377380
// get doc (from cache) and ensure it exists, *is* from the cache, and
378381
// matches the newData.
379382
FIRDocumentSnapshot *result =
380-
[self readDocumentForRef:doc options:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]];
383+
[self readDocumentForRef:doc
384+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]];
381385
XCTAssertTrue(result.exists);
382386
XCTAssertTrue(result.metadata.fromCache);
383387
XCTAssertTrue(result.metadata.hasPendingWrites);
384388
XCTAssertEqualObjects(result.data, newData);
385389

386390
// attempt to get doc (with default get options)
387-
result =
388-
[self readDocumentForRef:doc options:[[FIRGetOptions alloc] initWithSource:FIRSourceDefault]];
391+
result = [self readDocumentForRef:doc
392+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceDefault]];
389393
XCTAssertTrue(result.exists);
390394
XCTAssertTrue(result.metadata.fromCache);
391395
XCTAssertTrue(result.metadata.hasPendingWrites);
392396
XCTAssertEqualObjects(result.data, newData);
393397

394398
// attempt to get doc (from the server) and ensure it cannot be retreived
395399
XCTestExpectation *failedGetDocCompletion = [self expectationWithDescription:@"failedGetDoc"];
396-
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]
400+
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]
397401
completion:^(FIRDocumentSnapshot *snapshot, NSError *error) {
398402
XCTAssertNotNil(error);
399403
XCTAssertEqualObjects(error.domain, FIRFirestoreErrorDomain);
@@ -437,7 +441,7 @@ - (void)testGetCollectionWhileOfflineWithDifferentGetOptions {
437441
// matches the updated data.
438442
FIRQuerySnapshot *result =
439443
[self readDocumentSetForRef:col
440-
options:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]];
444+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]];
441445
XCTAssertTrue(result.metadata.fromCache);
442446
XCTAssertTrue(result.metadata.hasPendingWrites);
443447
XCTAssertEqualObjects(FIRQuerySnapshotGetData(result), (@[
@@ -454,7 +458,7 @@ - (void)testGetCollectionWhileOfflineWithDifferentGetOptions {
454458

455459
// attempt to get docs (with default get options)
456460
result = [self readDocumentSetForRef:col
457-
options:[[FIRGetOptions alloc] initWithSource:FIRSourceDefault]];
461+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceDefault]];
458462
XCTAssertTrue(result.metadata.fromCache);
459463
XCTAssertEqualObjects(FIRQuerySnapshotGetData(result), (@[
460464
@{@"key1" : @"value1"}, @{@"key2" : @"value2", @"key2b" : @"value2b"},
@@ -470,7 +474,7 @@ - (void)testGetCollectionWhileOfflineWithDifferentGetOptions {
470474

471475
// attempt to get docs (from the server) and ensure they cannot be retreived
472476
XCTestExpectation *failedGetDocsCompletion = [self expectationWithDescription:@"failedGetDocs"];
473-
[col getDocumentsWithOptions:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]
477+
[col getDocumentsWithOptions:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]
474478
completion:^(FIRQuerySnapshot *snapshot, NSError *error) {
475479
XCTAssertNotNil(error);
476480
XCTAssertEqualObjects(error.domain, FIRFirestoreErrorDomain);
@@ -543,7 +547,7 @@ - (void)testGetNonExistingDocWhileOnlineCacheOnly {
543547
// certain documents *don't* exist.
544548
XCTestExpectation *getNonExistingDocCompletion =
545549
[self expectationWithDescription:@"getNonExistingDoc"];
546-
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]
550+
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]
547551
completion:^(FIRDocumentSnapshot *snapshot, NSError *error) {
548552
XCTAssertNotNil(error);
549553
XCTAssertEqualObjects(error.domain, FIRFirestoreErrorDomain);
@@ -559,7 +563,7 @@ - (void)testGetNonExistingCollectionWhileOnlineCacheOnly {
559563
// get collection and ensure it's empty and that it *is* from the cache.
560564
FIRQuerySnapshot *snapshot =
561565
[self readDocumentSetForRef:col
562-
options:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]];
566+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]];
563567
XCTAssertEqual(snapshot.count, 0);
564568
XCTAssertEqual(snapshot.documentChanges.count, 0);
565569
XCTAssertTrue(snapshot.metadata.fromCache);
@@ -577,7 +581,7 @@ - (void)testGetNonExistingDocWhileOfflineCacheOnly {
577581
// certain documents *don't* exist.
578582
XCTestExpectation *getNonExistingDocCompletion =
579583
[self expectationWithDescription:@"getNonExistingDoc"];
580-
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]
584+
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]
581585
completion:^(FIRDocumentSnapshot *snapshot, NSError *error) {
582586
XCTAssertNotNil(error);
583587
XCTAssertEqualObjects(error.domain, FIRFirestoreErrorDomain);
@@ -596,7 +600,7 @@ - (void)testGetNonExistingCollectionWhileOfflineCacheOnly {
596600
// get collection and ensure it's empty and that it *is* from the cache.
597601
FIRQuerySnapshot *snapshot =
598602
[self readDocumentSetForRef:col
599-
options:[[FIRGetOptions alloc] initWithSource:FIRSourceCache]];
603+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceCache]];
600604
XCTAssertEqual(snapshot.count, 0);
601605
XCTAssertEqual(snapshot.documentChanges.count, 0);
602606
XCTAssertTrue(snapshot.metadata.fromCache);
@@ -608,7 +612,8 @@ - (void)testGetNonExistingDocWhileOnlineServerOnly {
608612

609613
// get doc and ensure that it does not exist and is *not* from the cache.
610614
FIRDocumentSnapshot *snapshot =
611-
[self readDocumentForRef:doc options:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]];
615+
[self readDocumentForRef:doc
616+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]];
612617
XCTAssertFalse(snapshot.exists);
613618
XCTAssertFalse(snapshot.metadata.fromCache);
614619
XCTAssertFalse(snapshot.metadata.hasPendingWrites);
@@ -620,7 +625,7 @@ - (void)testGetNonExistingCollectionWhileOnlineServerOnly {
620625
// get collection and ensure that it's empty and that it's *not* from the cache.
621626
FIRQuerySnapshot *snapshot =
622627
[self readDocumentSetForRef:col
623-
options:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]];
628+
options:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]];
624629
XCTAssertEqual(snapshot.count, 0);
625630
XCTAssertEqual(snapshot.documentChanges.count, 0);
626631
XCTAssertFalse(snapshot.metadata.fromCache);
@@ -638,7 +643,7 @@ - (void)testGetNonExistingDocWhileOfflineServerOnly {
638643
// certain documents *don't* exist.
639644
XCTestExpectation *getNonExistingDocCompletion =
640645
[self expectationWithDescription:@"getNonExistingDoc"];
641-
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]
646+
[doc getDocumentWithOptions:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]
642647
completion:^(FIRDocumentSnapshot *snapshot, NSError *error) {
643648
XCTAssertNotNil(error);
644649
XCTAssertEqualObjects(error.domain, FIRFirestoreErrorDomain);
@@ -656,7 +661,7 @@ - (void)testGetNonExistingCollectionWhileOfflineServerOnly {
656661

657662
// attempt to get collection and ensure that it cannot be retreived
658663
XCTestExpectation *failedGetDocsCompletion = [self expectationWithDescription:@"failedGetDocs"];
659-
[col getDocumentsWithOptions:[[FIRGetOptions alloc] initWithSource:FIRSourceServer]
664+
[col getDocumentsWithOptions:[[FIRGetOptions alloc] initWithSource:FIRGetSourceServer]
660665
completion:^(FIRQuerySnapshot *snapshot, NSError *error) {
661666
XCTAssertNotNil(error);
662667
XCTAssertEqualObjects(error.domain, FIRFirestoreErrorDomain);

Firestore/Source/API/FIRDocumentReference.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ - (void)getDocumentWithCompletion:(void (^)(FIRDocumentSnapshot *_Nullable docum
216216
- (void)getDocumentWithOptions:(FIRGetOptions *)options
217217
completion:(void (^)(FIRDocumentSnapshot *_Nullable document,
218218
NSError *_Nullable error))completion {
219-
if (options.source == FIRSourceCache) {
219+
if (options.source == FIRGetSourceCache) {
220220
[self.firestore.client getDocumentFromLocalCache:self completion:completion];
221221
return;
222222
}
@@ -256,17 +256,17 @@ - (void)getDocumentWithOptions:(FIRGetOptions *)options
256256
@"Failed to get document because the client is offline.",
257257
}]);
258258
} else if (snapshot.exists && snapshot.metadata.fromCache &&
259-
options.source == FIRSourceServer) {
260-
completion(nil,
261-
[NSError errorWithDomain:FIRFirestoreErrorDomain
262-
code:FIRFirestoreErrorCodeUnavailable
263-
userInfo:@{
264-
NSLocalizedDescriptionKey :
265-
@"Failed to get document from server. (However, this "
266-
@"document does exist in the local cache. Run again "
267-
@"without setting FIRSourceServer in the FIRGetOptions to "
268-
@"retrieve the cached document.)"
269-
}]);
259+
options.source == FIRGetSourceServer) {
260+
completion(
261+
nil, [NSError errorWithDomain:FIRFirestoreErrorDomain
262+
code:FIRFirestoreErrorCodeUnavailable
263+
userInfo:@{
264+
NSLocalizedDescriptionKey :
265+
@"Failed to get document from server. (However, this "
266+
@"document does exist in the local cache. Run again "
267+
@"without setting FIRGetSourceServer in the FIRGetOptions to "
268+
@"retrieve the cached document.)"
269+
}]);
270270
} else {
271271
completion(snapshot, nil);
272272
}

Firestore/Source/API/FIRGetOptions+Internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
2121
@interface FIRGetOptions ()
2222

2323
/** Where getDocument[s] calls should get their data from. */
24-
@property(nonatomic, readonly, getter=source) FIRSource source;
24+
@property(nonatomic, readonly, getter=source) FIRGetSource source;
2525

2626
@end
2727

Firestore/Source/API/FIRGetOptions.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
@implementation FIRGetOptions
2222

2323
+ (FIRGetOptions *)defaultOptions {
24-
return [[FIRGetOptions alloc] initWithSource:FIRSourceDefault];
24+
return [[FIRGetOptions alloc] initWithSource:FIRGetSourceDefault];
2525
}
2626

27-
- (instancetype)initWithSource:(FIRSource)source {
27+
- (instancetype)initWithSource:(FIRGetSource)source {
2828
if (self = [super init]) {
2929
_source = source;
3030
}

Firestore/Source/API/FIRQuery.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ - (void)getDocumentsWithCompletion:(void (^)(FIRQuerySnapshot *_Nullable snapsho
138138
- (void)getDocumentsWithOptions:(FIRGetOptions *)options
139139
completion:(void (^)(FIRQuerySnapshot *_Nullable snapshot,
140140
NSError *_Nullable error))completion {
141-
if (options.source == FIRSourceCache) {
141+
if (options.source == FIRGetSourceCache) {
142142
[self.firestore.client getDocumentsFromLocalCache:self completion:completion];
143143
return;
144144
}
@@ -161,17 +161,17 @@ - (void)getDocumentsWithOptions:(FIRGetOptions *)options
161161
dispatch_semaphore_wait(registered, DISPATCH_TIME_FOREVER);
162162
[listenerRegistration remove];
163163

164-
if (snapshot.metadata.fromCache && options.source == FIRSourceServer) {
165-
completion(nil,
166-
[NSError errorWithDomain:FIRFirestoreErrorDomain
167-
code:FIRFirestoreErrorCodeUnavailable
168-
userInfo:@{
169-
NSLocalizedDescriptionKey :
170-
@"Failed to get documents from server. (However, these "
171-
@"documents may exist in the local cache. Run again "
172-
@"without setting FIRSourceServer in the FIRGetOptions to "
173-
@"retrieve the cached documents.)"
174-
}]);
164+
if (snapshot.metadata.fromCache && options.source == FIRGetSourceServer) {
165+
completion(
166+
nil, [NSError errorWithDomain:FIRFirestoreErrorDomain
167+
code:FIRFirestoreErrorCodeUnavailable
168+
userInfo:@{
169+
NSLocalizedDescriptionKey :
170+
@"Failed to get documents from server. (However, these "
171+
@"documents may exist in the local cache. Run again "
172+
@"without setting FIRGetSourceServer in the FIRGetOptions to "
173+
@"retrieve the cached documents.)"
174+
}]);
175175
} else {
176176
completion(snapshot, nil);
177177
}

0 commit comments

Comments
 (0)