File tree Expand file tree Collapse file tree
Sources/CheckoutNetworkFakeClient Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ final public class CheckoutNetworkFakeClient: CheckoutClientInterface {
1313
1414 public var calledAsyncRequests : [ RequestConfiguration ] = [ ]
1515 public var dataToBeReturned : Decodable !
16+ public var errorToBeThrown : CheckoutNetworkError ?
1617
1718 public func runRequest< T: Decodable > ( with configuration: RequestConfiguration ,
1819 completionHandler: @escaping CompletionHandler < T > ) {
@@ -29,13 +30,19 @@ extension CheckoutNetworkFakeClient {
2930 public func runRequest< T: Decodable > ( with configuration: CheckoutNetwork . RequestConfiguration ) async throws -> T {
3031 calledAsyncRequests. append ( configuration)
3132 // swiftlint:disable force_cast
32- return dataToBeReturned as! T
33+ guard let error = errorToBeThrown else {
34+ return dataToBeReturned as! T
35+ }
36+ throw error
3337 // swiftlint:enable force_cast
3438 }
3539
3640 public func runRequest( with configuration: RequestConfiguration ) async throws {
3741 calledAsyncRequests. append ( configuration)
3842 try await Task . sleep ( nanoseconds: 1 * 1_000_000_000 ) // 1 second
39- return ( )
43+ guard let error = errorToBeThrown else {
44+ return ( )
45+ }
46+ throw error
4047 }
4148}
You can’t perform that action at this time.
0 commit comments