Skip to content

Commit 354f90b

Browse files
committed
Alternative approach
1 parent 9ce8922 commit 354f90b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

FirebaseRemoteConfig/SwiftNew/ConfigFetch.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ extension Installations: InstallationsProtocol {}
107107

108108
/// Provide fetchSession for tests to override.
109109
/// - Note: Managed internally by the fetch instance.
110-
public var fetchSession: any RCNConfigFetchSession
110+
private var fetchSession: any RCNConfigFetchSession
111+
112+
public var configuredFetchSessionProvider: (ConfigSettings) -> RCNConfigFetchSession {
113+
didSet {
114+
fetchSession = configuredFetchSessionProvider(settings)
115+
}
116+
}
111117

112118
private let namespace: String
113119

@@ -138,8 +144,6 @@ extension Installations: InstallationsProtocol {}
138144
)
139145
}
140146

141-
private let configuredFetchSessionProvider: (ConfigSettings) -> RCNConfigFetchSession
142-
143147
/// Designated initializer
144148
@objc public init(content: ConfigContent,
145149
DBManager: ConfigDBManager,
@@ -180,13 +184,8 @@ extension Installations: InstallationsProtocol {}
180184
super.init()
181185
}
182186

183-
public var disableNetworkSessionRecreation: Bool = false
184-
185187
/// Add the ability to update NSURLSession's timeout after a session has already been created.
186188
@objc public func recreateNetworkSession() {
187-
if disableNetworkSessionRecreation {
188-
return
189-
}
190189
fetchSession.invalidateAndCancel()
191190
fetchSession = configuredFetchSessionProvider(settings)
192191
}

FirebaseRemoteConfig/Tests/Swift/SwiftAPI/APITestBase.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ class APITestBase: XCTestCase {
9898
config.configRealtime = RealtimeMocks.mockRealtime(config.configRealtime)
9999
}
100100
fakeConsole = FakeConsole()
101-
config.configFetch.fetchSession = URLSessionMock(with: fakeConsole)
102-
config.configFetch.disableNetworkSessionRecreation = true
101+
config.configFetch.configuredFetchSessionProvider = { _ in
102+
URLSessionMock(with: self.fakeConsole)
103+
}
103104

104105
fakeConsole.config = [Constants.key1: Constants.value1,
105106
Constants.jsonKey: jsonValue,

0 commit comments

Comments
 (0)