Skip to content

Commit

Permalink
Fix incorrect decoding of timeout property in network configuration (c…
Browse files Browse the repository at this point in the history
…lose #902)
  • Loading branch information
matus-tomlein committed Jul 16, 2024
1 parent b01a810 commit 364c43b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Sources/Snowplow/Configurations/NetworkConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ public class NetworkConfiguration: SerializableConfiguration, ConfigurationProto
_method = HttpMethodOptions(rawValue: coder.decodeInteger(forKey: "method"))
_customPostPath = coder.decodeObject(forKey: "customPostPath") as? String
_requestHeaders = coder.decodeObject(forKey: "requestHeaders") as? [String : String]
_timeout = coder.decodeObject(forKey: "timeout") as? TimeInterval
if coder.containsValue(forKey: "timeout") {
_timeout = coder.decodeDouble(forKey: "timeout")
}
}
}
5 changes: 4 additions & 1 deletion Tests/Configurations/TestRemoteConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ class TestRemoteConfiguration: XCTestCase {

#if os(iOS) || os(macOS)
func testCache() {
let bundle = ConfigurationBundle(namespace: "namespace", networkConfiguration: NetworkConfiguration(endpoint: "endpoint"))
let networkConfig = NetworkConfiguration(endpoint: "endpoint")
networkConfig.timeout = 100
let bundle = ConfigurationBundle(namespace: "namespace", networkConfiguration: networkConfig)
let expected = RemoteConfigurationBundle(schema: "http://iglucentral.com/schemas/com.snowplowanalytics.mobile/remote_config/jsonschema/1-0-0", configurationVersion: 12)
expected.configurationBundle = [bundle]

Expand All @@ -119,6 +121,7 @@ class TestRemoteConfiguration: XCTestCase {
let expectedBundle = expected.configurationBundle[0]
let configBundle = config?.configurationBundle[0]
XCTAssertEqual(expectedBundle.networkConfiguration?.endpoint, configBundle?.networkConfiguration?.endpoint)
XCTAssertEqual(configBundle?.networkConfiguration?.timeout, 100)
XCTAssertNil(configBundle?.trackerConfiguration)
}

Expand Down

0 comments on commit 364c43b

Please sign in to comment.