From b3ce8fe645e9b28609f6c917375ee265510ab246 Mon Sep 17 00:00:00 2001 From: Jeremy Massel Date: Wed, 25 Mar 2020 16:24:20 -0600 Subject: [PATCH] Move NetworkResultCallback inside the class This makes it more consistent --- .../Services/EventLoggingNetworkService.swift | 5 ++--- Automattic-Tracks-iOSTests/Test Helpers/Mocks.swift | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Automattic-Tracks-iOS/Services/EventLoggingNetworkService.swift b/Automattic-Tracks-iOS/Services/EventLoggingNetworkService.swift index 8df5b518..572f7362 100644 --- a/Automattic-Tracks-iOS/Services/EventLoggingNetworkService.swift +++ b/Automattic-Tracks-iOS/Services/EventLoggingNetworkService.swift @@ -1,9 +1,8 @@ import Foundation -typealias NetworkResultCallback = (Result) -> Void - open class EventLoggingNetworkService { + typealias ResultCallback = (Result) -> Void private let urlSession: URLSession @@ -11,7 +10,7 @@ open class EventLoggingNetworkService { self.urlSession = urlSession } - func uploadFile(request: URLRequest, fileURL: URL, completion: @escaping NetworkResultCallback) { + func uploadFile(request: URLRequest, fileURL: URL, completion: @escaping ResultCallback) { urlSession.uploadTask(with: request, fromFile: fileURL, completionHandler: { data, response, error in if let error = error { diff --git a/Automattic-Tracks-iOSTests/Test Helpers/Mocks.swift b/Automattic-Tracks-iOSTests/Test Helpers/Mocks.swift index f116e1cc..b0635f82 100644 --- a/Automattic-Tracks-iOSTests/Test Helpers/Mocks.swift +++ b/Automattic-Tracks-iOSTests/Test Helpers/Mocks.swift @@ -78,7 +78,7 @@ class MockEventLoggingDelegate: EventLoggingDelegate { class MockEventLoggingNetworkService: EventLoggingNetworkService { var shouldSucceed = true - override func uploadFile(request: URLRequest, fileURL: URL, completion: @escaping NetworkResultCallback) { + override func uploadFile(request: URLRequest, fileURL: URL, completion: @escaping EventLoggingNetworkService.ResultCallback) { shouldSucceed ? completion(.success(Data())) : completion(.failure(MockError.generic)) } }