Skip to content

Commit 4b37e95

Browse files
committed
Checks for nil applicationId and clientKey
1 parent 9cf8988 commit 4b37e95

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Parse/Parse.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ + (void)initialize {
5555
///--------------------------------------
5656

5757
+ (void)setApplicationId:(NSString *)applicationId clientKey:(NSString *)clientKey {
58-
// TODO: (nlutsenko) Add assert and unit test here that checks applicationId, clientKey not being nil.
59-
58+
PFConsistencyAssert([applicationId length], @"'applicationId' should not be nil.");
59+
PFConsistencyAssert([clientKey length], @"'clientKey' should not be nil.");
60+
6061
// Setup new manager first, so it's 100% ready whenever someone sends a request for anything.
6162
ParseManager *manager = [[ParseManager alloc] initWithApplicationId:applicationId clientKey:clientKey];
6263
[manager configureWithApplicationGroupIdentifier:applicationGroupIdentifier_

Tests/Unit/ParseSetupUnitTests.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,12 @@ - (void)testInitializeWithLDSAfterInitializeShouldThrowException {
4545
[Parse setApplicationId:@"a" clientKey:@"b"];
4646
PFAssertThrowsInconsistencyException([Parse enableLocalDatastore]);
4747
}
48+
49+
- (void)testInitializeWithNilApplicationIdNilClientKeyShouldThrowException {
50+
NSString *yolo = nil;
51+
PFAssertThrowsInconsistencyException([Parse setApplicationId:yolo clientKey:yolo]);
52+
PFAssertThrowsInconsistencyException([Parse setApplicationId:yolo clientKey:@"a"]);
53+
PFAssertThrowsInconsistencyException([Parse setApplicationId:@"a" clientKey:yolo]);
54+
}
55+
4856
@end

0 commit comments

Comments
 (0)