Skip to content

Commit a168d28

Browse files
committed
Exposed reachability in API category and using for OutgoingMutationQueue retries
1 parent cb0323e commit a168d28

File tree

15 files changed

+209
-25
lines changed

15 files changed

+209
-25
lines changed

Amplify.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
2CFB61C7E80D065C0A885A2F /* Pods_Amplify_AWSPluginsCore_AWSPluginsTestConfigs_AWSPluginsTestCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5363CAF9EFAA822FED56808 /* Pods_Amplify_AWSPluginsCore_AWSPluginsTestConfigs_AWSPluginsTestCommon.framework */; };
9999
3263D332138415AF42E64FF7 /* Pods_AmplifyTestApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDC7F1C368154B364CB74742 /* Pods_AmplifyTestApp.framework */; };
100100
6B33896823AAACC900561E5B /* ReachabilityUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B33896723AAACC900561E5B /* ReachabilityUpdate.swift */; };
101+
6B767FB723AC092800C683ED /* AmplifyAPICategory+ReachabilityBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B767FB623AC092800C683ED /* AmplifyAPICategory+ReachabilityBehavior.swift */; };
102+
6B767FB923AC0A0D00C683ED /* APICategoryReachabilityBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B767FB823AC0A0D00C683ED /* APICategoryReachabilityBehavior.swift */; };
101103
6BB7441023A9954900B0EB6C /* DispatchSource+MakeOneOff.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BB7440F23A9954900B0EB6C /* DispatchSource+MakeOneOff.swift */; };
102104
6BBECD7123ADA7E100C8DFBE /* AmplifyAWSServiceConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BBECD7023ADA7E100C8DFBE /* AmplifyAWSServiceConfiguration.swift */; };
103105
6BBECD7423ADA9D100C8DFBE /* AmplifyAWSServiceConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BBECD7323ADA9D100C8DFBE /* AmplifyAWSServiceConfigurationTests.swift */; };
@@ -654,6 +656,8 @@
654656
687B09E9348F8D29979A2404 /* Pods-Amplify-AmplifyAWSPlugins-AWSPinpointAnalyticsPlugin-AWSPinpointAnalyticsPluginTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Amplify-AmplifyAWSPlugins-AWSPinpointAnalyticsPlugin-AWSPinpointAnalyticsPluginTests.debug.xcconfig"; path = "Target Support Files/Pods-Amplify-AmplifyAWSPlugins-AWSPinpointAnalyticsPlugin-AWSPinpointAnalyticsPluginTests/Pods-Amplify-AmplifyAWSPlugins-AWSPinpointAnalyticsPlugin-AWSPinpointAnalyticsPluginTests.debug.xcconfig"; sourceTree = "<group>"; };
655657
6AF0E4775809F0866F9C44D9 /* Pods-AmplifyAWSPlugins-AWSPluginsCore-AWSS3StoragePlugin-AWSS3StoragePluginTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AmplifyAWSPlugins-AWSPluginsCore-AWSS3StoragePlugin-AWSS3StoragePluginTests.debug.xcconfig"; path = "Target Support Files/Pods-AmplifyAWSPlugins-AWSPluginsCore-AWSS3StoragePlugin-AWSS3StoragePluginTests/Pods-AmplifyAWSPlugins-AWSPluginsCore-AWSS3StoragePlugin-AWSS3StoragePluginTests.debug.xcconfig"; sourceTree = "<group>"; };
656658
6B33896723AAACC900561E5B /* ReachabilityUpdate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReachabilityUpdate.swift; sourceTree = "<group>"; };
659+
6B767FB623AC092800C683ED /* AmplifyAPICategory+ReachabilityBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AmplifyAPICategory+ReachabilityBehavior.swift"; sourceTree = "<group>"; };
660+
6B767FB823AC0A0D00C683ED /* APICategoryReachabilityBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APICategoryReachabilityBehavior.swift; sourceTree = "<group>"; };
657661
6BAC32194A15ACB56F07DC87 /* Pods-AWSS3StoragePlugin.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AWSS3StoragePlugin.debug.xcconfig"; path = "Target Support Files/Pods-AWSS3StoragePlugin/Pods-AWSS3StoragePlugin.debug.xcconfig"; sourceTree = "<group>"; };
658662
6BB7440F23A9954900B0EB6C /* DispatchSource+MakeOneOff.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DispatchSource+MakeOneOff.swift"; sourceTree = "<group>"; };
659663
6BBECD7023ADA7E100C8DFBE /* AmplifyAWSServiceConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AmplifyAWSServiceConfiguration.swift; sourceTree = "<group>"; };
@@ -2037,10 +2041,12 @@
20372041
children = (
20382042
FAC428A1235F80000000F221 /* AmplifyAPICategory+GraphQLBehavior.swift */,
20392043
FAC428A3235F802A0000F221 /* AmplifyAPICategory+InterceptorBehavior.swift */,
2044+
6B767FB623AC092800C683ED /* AmplifyAPICategory+ReachabilityBehavior.swift */,
20402045
FAC4289F235F7F980000F221 /* AmplifyAPICategory+RESTBehavior.swift */,
20412046
FAC234FC227A053D00424678 /* APICategoryClientBehavior.swift */,
20422047
FA6BC87A235F5D240001A882 /* APICategoryGraphQLBehavior.swift */,
20432048
FA6BC87E235F5DAE0001A882 /* APICategoryInterceptorBehavior.swift */,
2049+
6B767FB823AC0A0D00C683ED /* APICategoryReachabilityBehavior.swift */,
20442050
FA6BC87C235F5D490001A882 /* APICategoryRESTBehavior.swift */,
20452051
);
20462052
path = ClientBehavior;
@@ -3475,6 +3481,7 @@
34753481
216879FE23636A0A004A056E /* RepeatingTimer.swift in Sources */,
34763482
FAC23542227A055200424678 /* Foundation+Utils.swift in Sources */,
34773483
FAA2E8D023A02AAD00E420EA /* StorageCategory+Resettable.swift in Sources */,
3484+
6B767FB723AC092800C683ED /* AmplifyAPICategory+ReachabilityBehavior.swift in Sources */,
34783485
FAD393712381FD3C00463F5E /* DataStoreCategory+Subscribe.swift in Sources */,
34793486
FAA64FC32397294600B9C3C6 /* ModelSchema+Attributes.swift in Sources */,
34803487
FAC0A2AF22B4400100B50912 /* LoggingCategory+ClientBehavior.swift in Sources */,
@@ -3670,6 +3677,7 @@
36703677
95DAAB32237E63370028544F /* EntityType.swift in Sources */,
36713678
FA0173372375FAA5005DDDFC /* HubError.swift in Sources */,
36723679
2142099623721F4400FA140C /* GraphQLOperationType.swift in Sources */,
3680+
6B767FB923AC0A0D00C683ED /* APICategoryReachabilityBehavior.swift in Sources */,
36733681
95DAAB36237E63370028544F /* Selection.swift in Sources */,
36743682
FAC0A2AD22B43FE700B50912 /* HubCategory+ClientBehavior.swift in Sources */,
36753683
FAAFAF2F23904B14002CF932 /* AtomicValue+Bool.swift in Sources */,

Amplify/Categories/API/ClientBehavior/APICategoryClientBehavior.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
public typealias APICategoryClientBehavior =
1010
APICategoryRESTBehavior &
1111
APICategoryGraphQLBehavior &
12-
APICategoryInterceptorBehavior
12+
APICategoryInterceptorBehavior &
13+
APICategoryReachabilityBehavior
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// Copyright 2018-2020 Amazon.com,
3+
// Inc. or its affiliates. All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Foundation
9+
import Combine
10+
public protocol APICategoryReachabilityBehavior {
11+
/// Attempts to create and start a reachability client for a host that corresponds to the apiName, and then
12+
/// returns the associated Publisher which vends ReachabiltyUpdates
13+
/// - Parameters:
14+
/// - for: The corresponding apiName that maps to the plugin configuration
15+
/// - Returns: A publisher that receives reachability updates, or nil if the reachability subsystem is unavailable
16+
@available(iOS 13.0, *)
17+
func reachabilityPublisher(for apiName: String?) throws -> AnyPublisher<ReachabilityUpdate, Never>?
18+
19+
@available(iOS 13.0, *)
20+
func reachabilityPublisher() throws -> AnyPublisher<ReachabilityUpdate, Never>?
21+
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright 2018-2020 Amazon.com,
3+
// Inc. or its affiliates. All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Foundation
9+
import Combine
10+
extension AmplifyAPICategory: APICategoryReachabilityBehavior {
11+
@available(iOS 13.0, *)
12+
public func reachabilityPublisher(for apiName: String?) throws -> AnyPublisher<ReachabilityUpdate, Never>? {
13+
return try plugin.reachabilityPublisher(for: apiName)
14+
}
15+
16+
@available(iOS 13.0, *)
17+
public func reachabilityPublisher() throws -> AnyPublisher<ReachabilityUpdate, Never>? {
18+
return try plugin.reachabilityPublisher(for: nil)
19+
}
20+
}

AmplifyPlugins/API/APICategoryPlugin.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
6B2E465A23AAA6AF0066EDCE /* NetworkReachabilityNotifierTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B2E465923AAA6AF0066EDCE /* NetworkReachabilityNotifierTests.swift */; };
106106
6B33896E23AABEEE00561E5B /* MockReachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B33896D23AABEEE00561E5B /* MockReachability.swift */; };
107107
6B33897023AABF1800561E5B /* NetworkReachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B33896F23AABF1800561E5B /* NetworkReachability.swift */; };
108+
6B33897223AAD94800561E5B /* AWSAPIPlugin+Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B33897123AAD94800561E5B /* AWSAPIPlugin+Reachability.swift */; };
108109
9B13EA5E48896E8B38883633 /* Pods_HostApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 930DD773E0FB4047393CA2AD /* Pods_HostApp.framework */; };
109110
A04815BCD5F9181C8AEDEF43 /* Pods_AWSAPICategoryPlugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 881AB4B98B48235DEC7754C2 /* Pods_AWSAPICategoryPlugin.framework */; };
110111
B1F5048F35638D3D142C4F1F /* Pods_AWSAPICategoryPlugin_AWSAPICategoryPluginTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B13CFC866A30622EDD91AF4 /* Pods_AWSAPICategoryPlugin_AWSAPICategoryPluginTests.framework */; };
@@ -374,6 +375,7 @@
374375
6B2E465923AAA6AF0066EDCE /* NetworkReachabilityNotifierTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkReachabilityNotifierTests.swift; sourceTree = "<group>"; };
375376
6B33896D23AABEEE00561E5B /* MockReachability.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockReachability.swift; sourceTree = "<group>"; };
376377
6B33896F23AABF1800561E5B /* NetworkReachability.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkReachability.swift; sourceTree = "<group>"; };
378+
6B33897123AAD94800561E5B /* AWSAPIPlugin+Reachability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AWSAPIPlugin+Reachability.swift"; sourceTree = "<group>"; };
377379
74EDB7008F5342ED4B38C9CA /* Pods_HostApp_AWSAPICategoryPluginIntegrationTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HostApp_AWSAPICategoryPluginIntegrationTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
378380
77792DD821FC754D857FC63C /* Pods-HostApp-AWSAPICategoryPluginTestCommon-GraphQLWithIAMIntegrationTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HostApp-AWSAPICategoryPluginTestCommon-GraphQLWithIAMIntegrationTests.release.xcconfig"; path = "Target Support Files/Pods-HostApp-AWSAPICategoryPluginTestCommon-GraphQLWithIAMIntegrationTests/Pods-HostApp-AWSAPICategoryPluginTestCommon-GraphQLWithIAMIntegrationTests.release.xcconfig"; sourceTree = "<group>"; };
379381
7866FCFB5807C2D20219CEBE /* Pods-HostApp-AWSAPICategoryPluginTestCommon-RESTWithIAMIntegrationTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HostApp-AWSAPICategoryPluginTestCommon-RESTWithIAMIntegrationTests.release.xcconfig"; path = "Target Support Files/Pods-HostApp-AWSAPICategoryPluginTestCommon-RESTWithIAMIntegrationTests/Pods-HostApp-AWSAPICategoryPluginTestCommon-RESTWithIAMIntegrationTests.release.xcconfig"; sourceTree = "<group>"; };
@@ -672,6 +674,7 @@
672674
21409C5D2384DE2C000A53C9 /* AWSAPIPlugin+GraphQLModelBehavior.swift */,
673675
21D7A099237B54D90057D00D /* AWSAPIPlugin+InterceptorBehavior.swift */,
674676
FA8EE784238632620097E4F1 /* AWSAPIPlugin+Log.swift */,
677+
6B33897123AAD94800561E5B /* AWSAPIPlugin+Reachability.swift */,
675678
21D7A096237B54D90057D00D /* AWSAPIPlugin+Resettable.swift */,
676679
21D7A0D0237B54D90057D00D /* AWSAPIPlugin+RESTBehavior.swift */,
677680
21D7A0D1237B54D90057D00D /* AWSAPIPlugin+URLSessionBehaviorDelegate.swift */,
@@ -2071,6 +2074,7 @@
20712074
21D7A105237B54D90057D00D /* ConnectionProviderError.swift in Sources */,
20722075
21D7A0DF237B54D90057D00D /* AWSGraphQLOperation.swift in Sources */,
20732076
21409C5E2384DE2C000A53C9 /* AWSAPIPlugin+GraphQLModelBehavior.swift in Sources */,
2077+
6B33897223AAD94800561E5B /* AWSAPIPlugin+Reachability.swift in Sources */,
20742078
FA8EE785238632620097E4F1 /* AWSAPIPlugin+Log.swift in Sources */,
20752079
21D7A10F237B54D90057D00D /* RESTOperationRequestUtils+Validator.swift in Sources */,
20762080
21D7A111237B54D90057D00D /* APIError+DecodingError.swift in Sources */,
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//
2+
// Copyright 2018-2020 Amazon.com,
3+
// Inc. or its affiliates. All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Amplify
9+
import Foundation
10+
import Combine
11+
import Reachability
12+
13+
extension AWSAPIPlugin {
14+
@available(iOS 13.0, *)
15+
public func reachabilityPublisher() throws -> AnyPublisher<ReachabilityUpdate, Never>? {
16+
return try reachabilityPublisher(for: nil)
17+
}
18+
19+
@available(iOS 13.0, *)
20+
public func reachabilityPublisher(for apiName: String?) throws -> AnyPublisher<ReachabilityUpdate, Never>? {
21+
let hostName = try determineHostName(apiName: apiName)
22+
if let networkReachability = reachabilityMap[hostName] {
23+
return networkReachability.publisher
24+
}
25+
do {
26+
let networkReachability = try NetworkReachabilityNotifier(host: hostName,
27+
allowsCellularAccess: true,
28+
reachabilityFactory: Reachability.self)
29+
reachabilityMap[hostName] = networkReachability
30+
return networkReachability.publisher
31+
} catch {
32+
Amplify.API.log.error("Unable to initialize NetworkReachabilityNotifier: \(error)")
33+
return nil
34+
}
35+
}
36+
37+
private func determineHostName(apiName: String?) throws -> String {
38+
if let apiName = apiName {
39+
guard let baseUrl = self.pluginConfig.endpoints[apiName]?.baseURL,
40+
let host = baseUrl.host else {
41+
let error = APIError.invalidConfiguration("Invalid endpoint configuration for \(apiName)",
42+
"""
43+
baseURL does not contain a valid hostname
44+
for apiName: \(apiName)
45+
"""
46+
)
47+
throw error
48+
}
49+
return host
50+
}
51+
52+
if pluginConfig.endpoints.count > 1 {
53+
let error = APIError.invalidConfiguration("Unable to determine which endpoint configuration",
54+
"""
55+
Pass in the apiName to disambiguate between which endpoint
56+
you are requesting reachability for
57+
"""
58+
)
59+
throw error
60+
}
61+
62+
guard let configEntry = self.pluginConfig.endpoints.first else {
63+
let error = APIError.invalidConfiguration("No API configurations found",
64+
"""
65+
Review how the API category is being instantiated and
66+
configured.
67+
"""
68+
)
69+
throw error
70+
}
71+
72+
guard let host = configEntry.value.baseURL.host else {
73+
let error = APIError.invalidConfiguration("Invalid endpoint configuration",
74+
"""
75+
baseURL does not contain a valid hostname
76+
"""
77+
)
78+
throw error
79+
}
80+
return host
81+
}
82+
83+
}

AmplifyPlugins/API/AWSAPICategoryPlugin/AWSAPIPlugin+Resettable.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ extension AWSAPIPlugin: Resettable {
2525

2626
authService = nil
2727

28+
if #available(iOS 13.0, *) {
29+
reachabilityMap.removeAll()
30+
}
31+
2832
subscriptionConnectionFactory = nil
2933

3034
onComplete()

AmplifyPlugins/API/AWSAPICategoryPlugin/AWSAPIPlugin.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2018-2019 Amazon.com,
2+
// Copyright 2018-2020 Amazon.com,
33
// Inc. or its affiliates. All Rights Reserved.
44
//
55
// SPDX-License-Identifier: Apache-2.0
@@ -9,7 +9,6 @@ import Amplify
99
import AWSPluginsCore
1010

1111
final public class AWSAPIPlugin: NSObject, APICategoryPlugin {
12-
1312
/// The unique key of the plugin within the API category.
1413
public var key: PluginKey {
1514
return "awsAPIPlugin"
@@ -38,6 +37,23 @@ final public class AWSAPIPlugin: NSObject, APICategoryPlugin {
3837
/// and is clearable by `reset()`. This is implicitly unwrapped to be destroyed when resetting.
3938
var subscriptionConnectionFactory: SubscriptionConnectionFactory!
4039

40+
/// The underlying map that retains instances of NetworkReachabilityNotifier. Using a computed property
41+
/// to work around @available for use on stored properties
42+
var iReachabilityMap: [String: Any]?
43+
44+
@available(iOS 13.0, *)
45+
var reachabilityMap: [String: NetworkReachabilityNotifier] {
46+
get {
47+
if iReachabilityMap == nil {
48+
iReachabilityMap = [String: NetworkReachabilityNotifier]()
49+
}
50+
return iReachabilityMap as! [String: NetworkReachabilityNotifier] // swiftlint:disable:this force_cast
51+
}
52+
set {
53+
iReachabilityMap = newValue
54+
}
55+
}
56+
4157
public init(modelRegistration: AmplifyModelRegistration? = nil,
4258
sessionFactory: URLSessionBehaviorFactory? = nil) {
4359

AmplifyPlugins/API/AWSAPICategoryPlugin/Reachability/NetworkReachabilityNotifier.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class NetworkReachabilityNotifier {
1515
private var reachability: NetworkReachabilityProviding?
1616
private var allowsCellularAccess = true
1717

18-
let reachabilityPublisher = PassthroughSubject<ReachabilityUpdate, DataStoreError>()
19-
var publisher: AnyPublisher<ReachabilityUpdate, DataStoreError> {
18+
let reachabilityPublisher = PassthroughSubject<ReachabilityUpdate, Never>()
19+
var publisher: AnyPublisher<ReachabilityUpdate, Never> {
2020
return reachabilityPublisher.eraseToAnyPublisher()
2121
}
2222

2323
public init(host: String,
2424
allowsCellularAccess: Bool,
25-
reachabilityFactory: NetworkReachabilityProvidingFactory.Type) {
25+
reachabilityFactory: NetworkReachabilityProvidingFactory.Type) throws {
2626
self.reachability = reachabilityFactory.make(for: host)
2727
self.allowsCellularAccess = allowsCellularAccess
2828

@@ -34,15 +34,14 @@ class NetworkReachabilityNotifier {
3434
do {
3535
try reachability?.startNotifier()
3636
} catch {
37-
//TODO: Test effects of inability to start ReachabilitySwift
38-
Amplify.DataStore.log.error("Unable to start notifier from ReachabilitySwift")
37+
throw error
3938
}
4039
}
4140

4241
deinit {
4342
reachability?.stopNotifier()
4443
NotificationCenter.default.removeObserver(self)
45-
reachabilityPublisher.send(completion: Subscribers.Completion<DataStoreError>.finished)
44+
reachabilityPublisher.send(completion: Subscribers.Completion<Never>.finished)
4645
}
4746

4847
// MARK: - Notifications

AmplifyPlugins/API/AWSAPICategoryPluginTests/Reachability/NetworkReachabilityNotifierTests.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ class NetworkReachabilityNotifierTests: XCTestCase {
1717
var notifier: NetworkReachabilityNotifier!
1818

1919
override func setUp() {
20-
notifier = NetworkReachabilityNotifier(host: "localhost",
21-
allowsCellularAccess: true,
22-
reachabilityFactory: MockNetworkReachabilityProvidingFactory.self)
20+
do {
21+
notifier = try NetworkReachabilityNotifier(host: "localhost",
22+
allowsCellularAccess: true,
23+
reachabilityFactory: MockNetworkReachabilityProvidingFactory.self)
24+
} catch {
25+
XCTFail("failed to init NetworkReachabilityNotifier")
26+
}
2327
MockReachability.iConnection = .wifi
2428
}
2529

0 commit comments

Comments
 (0)