File tree 1 file changed +18
-1
lines changed
FirebaseRemoteConfig/Tests/Swift/SwiftAPI
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,24 @@ class APITestBase: XCTestCase {
88
88
config. configRealtime = RealtimeMocks . mockRealtime ( config. configRealtime)
89
89
}
90
90
fakeConsole = FakeConsole ( )
91
- config. configFetch. fetchSession = URLSessionMock ( with: fakeConsole)
91
+ let configuration = URLSessionConfiguration . default
92
+ configuration. protocolClasses = [ MockURLProtocol . self]
93
+ config. configFetch. fetchSession = URLSession ( configuration: configuration)
94
+
95
+ var etag = " "
96
+ MockURLProtocol . requestHandler = { request in
97
+ let consoleValues = self . fakeConsole. get ( )
98
+ if etag == " " || consoleValues [ " state " ] as! String == RCNFetchResponseKeyStateUpdate {
99
+ // Time string in microseconds to insure a different string from previous change.
100
+ etag = String ( NSDate ( ) . timeIntervalSince1970)
101
+ }
102
+ let jsonData = try ! JSONSerialization . data ( withJSONObject: consoleValues)
103
+ let response = HTTPURLResponse ( url: URL ( fileURLWithPath: " fakeURL " ) ,
104
+ statusCode: 200 ,
105
+ httpVersion: nil ,
106
+ headerFields: [ " etag " : etag] )
107
+ return ( jsonData, response!)
108
+ }
92
109
93
110
fakeConsole. config = [ Constants . key1: Constants . value1,
94
111
Constants . jsonKey: jsonValue,
You can’t perform that action at this time.
0 commit comments