Skip to content

Commit

Permalink
really try to fix the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
themiswang committed Dec 7, 2023
1 parent 9d9b101 commit b079f62
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ NS_ASSUME_NONNULL_BEGIN
/// Cached instances of Remote Config objects.
@property(nonatomic, strong) NSMutableDictionary<NSString *, FIRRemoteConfig *> *instances;

/// Clear all the component instances from the singleton which created previously;
+ (void)clearAllComponentInstance;

/// Default method for retrieving a Remote Config instance, or creating one if it doesn't exist.
- (FIRRemoteConfig *)remoteConfigForNamespace:(NSString *)remoteConfigNamespace;

Expand Down
6 changes: 6 additions & 0 deletions FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ + (FIRRemoteConfigComponent *)getComponentForApp:(FIRApp *)app {
return nil;
}

+ (void)clearAllComponentInstance {
@synchronized(_componentInstances) {
[_componentInstances removeAllObjects];
}
}

/// Default method for retrieving a Remote Config instance, or creating one if it doesn't exist.
- (FIRRemoteConfig *)remoteConfigForNamespace:(NSString *)remoteConfigNamespace {
if (!remoteConfigNamespace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ - (void)tearDown {

// Clear out any apps that were called with `configure`.
[FIRApp resetApps];
[FIRRemoteConfigComponent clearAllComponentInstance];
}

- (void)testRCInstanceCreationAndCaching {
Expand Down
2 changes: 2 additions & 0 deletions FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import <OCMock/OCMock.h>
#import <XCTest/XCTest.h>

#import "FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.h"
#import "FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h"
#import "FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h"
#import "FirebaseRemoteConfig/Sources/Public/FirebaseRemoteConfig/FIRRemoteConfig.h"
Expand Down Expand Up @@ -286,6 +287,7 @@ __unsafe_unretained void (^handler)(FIRRemoteConfigFetchStatus status,

- (void)tearDown {
[_DBManager removeDatabaseOnDatabaseQueueAtPath:_DBPath];
[FIRRemoteConfigComponent clearAllComponentInstance];
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:_userDefaultsSuiteName];
[_DBManagerMock stopMocking];
_DBManagerMock = nil;
Expand Down

0 comments on commit b079f62

Please sign in to comment.