Skip to content

Commit b079f62

Browse files
committed
really try to fix the unit tests
1 parent 9d9b101 commit b079f62

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ NS_ASSUME_NONNULL_BEGIN
4747
/// Cached instances of Remote Config objects.
4848
@property(nonatomic, strong) NSMutableDictionary<NSString *, FIRRemoteConfig *> *instances;
4949

50+
/// Clear all the component instances from the singleton which created previously;
51+
+ (void)clearAllComponentInstance;
52+
5053
/// Default method for retrieving a Remote Config instance, or creating one if it doesn't exist.
5154
- (FIRRemoteConfig *)remoteConfigForNamespace:(NSString *)remoteConfigNamespace;
5255

FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ + (FIRRemoteConfigComponent *)getComponentForApp:(FIRApp *)app {
4040
return nil;
4141
}
4242

43+
+ (void)clearAllComponentInstance {
44+
@synchronized(_componentInstances) {
45+
[_componentInstances removeAllObjects];
46+
}
47+
}
48+
4349
/// Default method for retrieving a Remote Config instance, or creating one if it doesn't exist.
4450
- (FIRRemoteConfig *)remoteConfigForNamespace:(NSString *)remoteConfigNamespace {
4551
if (!remoteConfigNamespace) {

FirebaseRemoteConfig/Tests/Unit/FIRRemoteConfigComponentTest.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ - (void)tearDown {
3232

3333
// Clear out any apps that were called with `configure`.
3434
[FIRApp resetApps];
35+
[FIRRemoteConfigComponent clearAllComponentInstance];
3536
}
3637

3738
- (void)testRCInstanceCreationAndCaching {

FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#import <OCMock/OCMock.h>
1919
#import <XCTest/XCTest.h>
2020

21+
#import "FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.h"
2122
#import "FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h"
2223
#import "FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h"
2324
#import "FirebaseRemoteConfig/Sources/Public/FirebaseRemoteConfig/FIRRemoteConfig.h"
@@ -286,6 +287,7 @@ __unsafe_unretained void (^handler)(FIRRemoteConfigFetchStatus status,
286287

287288
- (void)tearDown {
288289
[_DBManager removeDatabaseOnDatabaseQueueAtPath:_DBPath];
290+
[FIRRemoteConfigComponent clearAllComponentInstance];
289291
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:_userDefaultsSuiteName];
290292
[_DBManagerMock stopMocking];
291293
_DBManagerMock = nil;

0 commit comments

Comments
 (0)