Skip to content

Commit 2441967

Browse files
committed
cleanup
1 parent 01f2cb0 commit 2441967

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ - (void)setConfigSettings:(FIRRemoteConfigSettings *)configSettings {
623623
self->_settings.minimumFetchInterval = configSettings.minimumFetchInterval;
624624
self->_settings.fetchTimeout = configSettings.fetchTimeout;
625625
/// The NSURLSession needs to be recreated whenever the fetch timeout may be updated.
626-
// [self->_configFetch recreateNetworkSession];
626+
// [self->_configFetch recreateNetworkSession];
627627
FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000067",
628628
@"Successfully set configSettings. Developer Mode: %@, Minimum Fetch Interval:%f, "
629629
@"Fetch timeout:%f",

FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#import <FirebaseRemoteConfig/FIRRemoteConfig.h>
1818

1919
#import <FirebaseAnalyticsInterop/FIRAnalyticsInterop.h>
20-
#import <FirebaseRemoteConfig/RCNConfigSettings.h>
2120
#import <FirebaseRemoteConfig/RCNConfigFetch.h>
21+
#import <FirebaseRemoteConfig/RCNConfigSettings.h>
2222

2323
@class FIROptions;
2424
@class RCNConfigContent;

FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ typedef void (^RCNConfigFetcherCompletion)(NSData *data, NSURLResponse *response
5353
/// Add the ability to update NSURLSession's timeout after a session has already been created.
5454
- (void)recreateNetworkSession;
5555

56+
/// Provide fetchSession for tests to override.
5657
@property(nonatomic, readwrite, strong, nonnull) NSURLSession *fetchSession;
5758

59+
/// Flag for tests to disable network accesses.
60+
@property(nonatomic, readwrite) BOOL testWithoutNetwork;
61+
5862
NS_ASSUME_NONNULL_END
5963

6064
@end

FirebaseRemoteConfig/Sources/RCNFetch.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ - (instancetype)initWithContent:(RCNConfigContent *)content
109109

110110
/// Force a new NSURLSession creation for updated config.
111111
- (void)recreateNetworkSession {
112+
if (self.testWithoutNetwork) {
113+
return;
114+
}
112115
if (_fetchSession) {
113116
[_fetchSession invalidateAndCancel];
114117
}
@@ -202,7 +205,7 @@ - (NSString *)FIRAppNameFromFullyQualifiedNamespace {
202205
/// requests to work.(b/14751422).
203206
- (void)refreshInstallationsTokenWithCompletionHandler:
204207
(FIRRemoteConfigFetchCompletion)completionHandler {
205-
if (YES) {
208+
if (self.testWithoutNetwork) {
206209
[self doFetchCall:completionHandler];
207210
return;
208211
}

FirebaseRemoteConfig/Tests/HermeticAPI/APITests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class APITests: XCTestCase {
3232
let settings = RemoteConfigSettings()
3333
settings.minimumFetchInterval = 0
3434
config.configSettings = settings
35-
config.configFetch.fetchSession = URLSessionMock.init()
35+
config.configFetch.fetchSession = URLSessionMock()
36+
config.configFetch.testWithoutNetwork = true
3637
FakeConsole.config = ["Key1": "Value1"]
3738

3839
// Uncomment for verbose debug logging.

FirebaseRemoteConfig/Tests/HermeticAPI/FakeConsole.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class FakeConsole {
2323
static func get() -> [String: AnyHashable] {
2424
if config.count == 0 {
2525
last = config
26-
return [ RCNFetchResponseKeyState : RCNFetchResponseKeyStateEmptyConfig ]
26+
return [RCNFetchResponseKeyState: RCNFetchResponseKeyStateEmptyConfig]
2727
}
2828
var state = RCNFetchResponseKeyStateNoChange
2929
if last != config {
3030
state = RCNFetchResponseKeyStateUpdate
3131
}
3232
last = config
33-
return [ RCNFetchResponseKeyState : state, RCNFetchResponseKeyEntries : config]
33+
return [RCNFetchResponseKeyState: state, RCNFetchResponseKeyEntries: config]
3434
}
3535
}

FirebaseRemoteConfig/Tests/HermeticAPI/URLSessionPartialMock.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class URLSessionMock: URLSession {
4545
etag = String(NSDate().timeIntervalSince1970)
4646
}
4747
let jsonData = try! JSONSerialization.data(withJSONObject: consoleValues)
48-
let response = HTTPURLResponse.init(url: URL.init(fileURLWithPath: "fakeURL"),
49-
statusCode: 200,
50-
httpVersion: nil,
51-
headerFields: ["etag": etag])
48+
let response = HTTPURLResponse(url: URL(fileURLWithPath: "fakeURL"),
49+
statusCode: 200,
50+
httpVersion: nil,
51+
headerFields: ["etag": etag])
5252
return URLSessionDataTaskMock {
5353
completionHandler(jsonData, response, nil)
5454
}

0 commit comments

Comments
 (0)