Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FirebaseRemoteConfig.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@ app update.
'FirebaseRemoteConfig/Tests/Unit/SecondApp-GoogleService-Info.plist'
unit_tests.requires_app_host = true
unit_tests.dependency 'OCMock'
unit_tests.requires_arc = true
end
end
76 changes: 38 additions & 38 deletions FirebaseRemoteConfig/Tests/Unit/RCNConfigDBManagerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ - (void)testV1NamespaceMigrationToV2Namespace {
XCTAssertTrue(success);
if (count == 100) {
// Migrate to the new namespace.
[_DBManager createOrOpenDatabase];
[_DBManager
[self->_DBManager createOrOpenDatabase];
[self->_DBManager
loadMainWithBundleIdentifier:bundleIdentifier
completionHandler:^(
BOOL loadSuccess,
Expand Down Expand Up @@ -125,18 +125,18 @@ - (void)testWriteAndLoadMainTableResult {
XCTAssertTrue(success);
if (count == 100) {
// check DB read correctly
[_DBManager loadMainWithBundleIdentifier:bundleIdentifier
completionHandler:^(BOOL success, NSDictionary *fetchedConfig,
NSDictionary *activeConfig,
NSDictionary *defaultConfig) {
NSMutableDictionary *res = [fetchedConfig mutableCopy];
XCTAssertTrue(success);
FIRRemoteConfigValue *value = res[namespace_p][@"key100"];
XCTAssertEqualObjects(value.stringValue, @"value100");
if (success) {
[loadConfigContentExpectation fulfill];
}
}];
[self->_DBManager loadMainWithBundleIdentifier:bundleIdentifier
completionHandler:^(BOOL success, NSDictionary *fetchedConfig,
NSDictionary *activeConfig,
NSDictionary *defaultConfig) {
NSMutableDictionary *res = [fetchedConfig mutableCopy];
XCTAssertTrue(success);
FIRRemoteConfigValue *value = res[namespace_p][@"key100"];
XCTAssertEqualObjects(value.stringValue, @"value100");
if (success) {
[loadConfigContentExpectation fulfill];
}
}];
}
};
NSString *value = [NSString stringWithFormat:@"value%d", i];
Expand Down Expand Up @@ -165,7 +165,7 @@ - (void)testWriteAndLoadInternalMetadataResult {
XCTAssertTrue(success);
if (count == 100) {
// check DB read correctly
NSDictionary *result = [_DBManager loadInternalMetadataTable];
NSDictionary *result = [self->_DBManager loadInternalMetadataTable];
NSString *stringValue = [[NSString alloc] initWithData:result[@"key100"]
encoding:NSUTF8StringEncoding];
XCTAssertEqualObjects(stringValue, @"value100");
Expand Down Expand Up @@ -232,7 +232,7 @@ - (void)testWriteAndLoadMetadataResult {
};

RCNDBCompletion completion = ^(BOOL success, NSDictionary *result1) {
NSDictionary *result = [_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
NSDictionary *result = [self->_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
XCTAssertNotNil(result);
XCTAssertEqualObjects(result[RCNKeyBundleIdentifier], bundleIdentifier);
XCTAssertEqual([result[RCNKeyFetchTime] doubleValue], lastFetchTimestamp);
Expand Down Expand Up @@ -274,12 +274,12 @@ - (void)testDeleteParamAndLoadMainTable {
XCTAssertTrue(success);

// Delete the key for given namespace.
[_DBManager deleteRecordFromMainTableWithNamespace:namespaceToDelete
bundleIdentifier:bundleIdentifier
fromSource:RCNDBSourceActive];
[self->_DBManager deleteRecordFromMainTableWithNamespace:namespaceToDelete
bundleIdentifier:bundleIdentifier
fromSource:RCNDBSourceActive];

// Read from the database and verify expected values.
[_DBManager
[self->_DBManager
loadMainWithBundleIdentifier:bundleIdentifier
completionHandler:^(BOOL success, NSDictionary *fetchedConfig,
NSDictionary *activeConfig, NSDictionary *defaultConfig) {
Expand All @@ -300,7 +300,7 @@ - (void)testDeleteParamAndLoadMainTable {
XCTAssertTrue(success);

// Ensure DB read succeeds.
[_DBManager
[self->_DBManager
loadMainWithBundleIdentifier:bundleIdentifier
completionHandler:^(BOOL success, NSDictionary *fetchedConfig,
NSDictionary *activeConfig, NSDictionary *defaultConfig) {
Expand Down Expand Up @@ -378,7 +378,7 @@ - (void)testWriteAndLoadExperiments {
experimentResults[@RCNExperimentTableKeyMetadata][@"experiment_new_metadata"]);
[updateAndLoadExperimentExpectation fulfill];
};
[_DBManager loadExperimentWithCompletionHandler:readCompletion];
[self->_DBManager loadExperimentWithCompletionHandler:readCompletion];
};

NSError *error;
Expand All @@ -387,9 +387,9 @@ - (void)testWriteAndLoadExperiments {
options:NSJSONWritingPrettyPrinted
error:&error];

[_DBManager insertExperimentTableWithKey:@RCNExperimentTableKeyMetadata
value:serializedMetadata
completionHandler:writeMetadataCompletion];
[self->_DBManager insertExperimentTableWithKey:@RCNExperimentTableKeyMetadata
value:serializedMetadata
completionHandler:writeMetadataCompletion];
};
[_DBManager insertExperimentTableWithKey:@RCNExperimentTableKeyPayload
value:[[NSData alloc] init]
Expand Down Expand Up @@ -455,15 +455,15 @@ - (void)testUpdateAndloadLastFetchStatus {

// Metadata row must exist before update
RCNDBCompletion createMetadataCompletion = ^(BOOL success, NSDictionary *createResult) {
NSDictionary *result = [_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
NSDictionary *result = [self->_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
XCTAssertTrue(success);
XCTAssertNotNil(result);
XCTAssertEqual([result[RCNKeyLastFetchStatus] intValue],
(int)FIRRemoteConfigFetchStatusSuccess);
XCTAssertEqual([result[RCNKeyLastFetchError] intValue], (int)FIRRemoteConfigErrorUnknown);

RCNDBCompletion updateMetadataCompletion = ^(BOOL success, NSDictionary *updateResult) {
NSDictionary *result = [_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
NSDictionary *result = [self->_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];

XCTAssertTrue(success);
XCTAssertNotNil(result);
Expand All @@ -473,7 +473,7 @@ - (void)testUpdateAndloadLastFetchStatus {
[updateAndLoadMetadataExpectation fulfill];
};
// Update with throttle status.
[_DBManager
[self->_DBManager
updateMetadataWithOption:RCNUpdateOptionFetchStatus
values:@[
@(FIRRemoteConfigFetchStatusThrottled), @(FIRRemoteConfigErrorThrottled)
Expand All @@ -498,21 +498,21 @@ - (void)ignore_InsertAndUpdateApplyTime {
RCNDBCompletion createMetadataCompletion = ^(BOOL success, NSDictionary *createResult) {
XCTAssertTrue(success);
// Read newly created metadata.
NSDictionary *result = [_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
NSDictionary *result = [self->_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
XCTAssertNotNil(result);
XCTAssertEqual([result[RCNKeyLastApplyTime] doubleValue], (double)100);
RCNDBCompletion updateMetadataCompletion = ^(BOOL success, NSDictionary *updateResult) {
NSDictionary *result = [_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
NSDictionary *result = [self->_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];

XCTAssertTrue(success);
XCTAssertNotNil(result);
XCTAssertEqual([result[RCNKeyLastApplyTime] doubleValue], lastApplyTimestamp);
[updateAndLoadMetadataExpectation fulfill];
};
// Update apply config timestamp.
[_DBManager updateMetadataWithOption:RCNUpdateOptionApplyTime
values:@[ @(lastApplyTimestamp) ]
completionHandler:updateMetadataCompletion];
[self->_DBManager updateMetadataWithOption:RCNUpdateOptionApplyTime
values:@[ @(lastApplyTimestamp) ]
completionHandler:updateMetadataCompletion];
};

[_DBManager insertMetadataTableWithValues:[self createSampleMetadata]
Expand All @@ -528,22 +528,22 @@ - (void)testUpdateAndLoadSetDefaultsTime {

// Metadata row must exist before update
RCNDBCompletion createMetadataCompletion = ^(BOOL success, NSDictionary *createResult) {
NSDictionary *result = [_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
NSDictionary *result = [self->_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
XCTAssertTrue(success);
XCTAssertNotNil(result);
XCTAssertEqual([result[RCNKeyLastSetDefaultsTime] doubleValue], (double)200);
RCNDBCompletion updateMetadataCompletion = ^(BOOL success, NSDictionary *updateResult) {
NSDictionary *result = [_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];
NSDictionary *result = [self->_DBManager loadMetadataWithBundleIdentifier:bundleIdentifier];

XCTAssertTrue(success);
XCTAssertNotNil(result);
XCTAssertEqual([result[RCNKeyLastSetDefaultsTime] doubleValue], lastSetDefaultsTimestamp);
[updateAndLoadMetadataExpectation fulfill];
};
// Update setting default config timestamp.
[_DBManager updateMetadataWithOption:RCNUpdateOptionDefaultTime
values:@[ @(lastSetDefaultsTimestamp) ]
completionHandler:updateMetadataCompletion];
[self->_DBManager updateMetadataWithOption:RCNUpdateOptionDefaultTime
values:@[ @(lastSetDefaultsTimestamp) ]
completionHandler:updateMetadataCompletion];
};

[_DBManager insertMetadataTableWithValues:[self createSampleMetadata]
Expand Down
2 changes: 1 addition & 1 deletion FirebaseRemoteConfig/Tests/Unit/RCNInstanceIDTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ - (void)testMultipleFetchCallsFailing {
rangeOfString:@"Failed to get InstanceID token"]
.location == NSNotFound);
// Make a second fetch call.
[_configInstances[i]
[self->_configInstances[i]
fetchWithExpirationDuration:43200
completionHandler:^void(FIRRemoteConfigFetchStatus status, NSError *error) {
XCTAssertNotNil(error);
Expand Down
Loading