diff --git a/Tests/MultipartFormDataParserTests/MultipartFormDataParserTests.swift b/Tests/MultipartFormDataParserTests/MultipartFormDataParserTests.swift index fc53a00..5299889 100644 --- a/Tests/MultipartFormDataParserTests/MultipartFormDataParserTests.swift +++ b/Tests/MultipartFormDataParserTests/MultipartFormDataParserTests.swift @@ -122,9 +122,11 @@ final class MultipartFormDataParserTests: XCTestCase { let message = Data("Hello world!".utf8) try runActivity(named: "request") { - let request = try requestWithAPIKit(genbaNeko: genbaNeko, - denwaNeko: denwaNeko, - message: message) + let request = try requestWithAPIKit( + genbaNeko: genbaNeko, + denwaNeko: denwaNeko, + message: message + ) let data = try MultipartFormData.parse(from: request) XCTAssertEqual(data.element(forName: "genbaNeko")?.data, genbaNeko) XCTAssertEqual(data.element(forName: "denwaNeko")?.data, denwaNeko) diff --git a/Tests/MultipartFormDataParserTests/_TestFunctions/TestFunction_Moya.swift b/Tests/MultipartFormDataParserTests/_TestFunctions/TestFunction_Moya.swift index 335c89b..ddd36d7 100644 --- a/Tests/MultipartFormDataParserTests/_TestFunctions/TestFunction_Moya.swift +++ b/Tests/MultipartFormDataParserTests/_TestFunctions/TestFunction_Moya.swift @@ -45,12 +45,14 @@ extension XCTestCase { case let .failure(error): if retryCount > 0 { print("retry: \(retryCount)") - return try uploadWithMoya(genbaNeko: genbaNeko, - denwaNeko: denwaNeko, - message: message, - retryCount: retryCount - 1, - file: file, - line: line) + return try uploadWithMoya( + genbaNeko: genbaNeko, + denwaNeko: denwaNeko, + message: message, + retryCount: retryCount - 1, + file: file, + line: line + ) } throw error } diff --git a/Tests/MultipartFormDataParserTests/_TestFunctions/TestFunction_URLSession.swift b/Tests/MultipartFormDataParserTests/_TestFunctions/TestFunction_URLSession.swift index a16dfe0..3c7129e 100644 --- a/Tests/MultipartFormDataParserTests/_TestFunctions/TestFunction_URLSession.swift +++ b/Tests/MultipartFormDataParserTests/_TestFunctions/TestFunction_URLSession.swift @@ -25,12 +25,14 @@ extension XCTestCase { return try JSONDecoder().decode(TestEntity.self, from: data) } catch { guard retryCount > 0 else { throw error } - return try await uploadURLSessionData(genbaNeko: genbaNeko, - denwaNeko: denwaNeko, - message: message, - retryCount: retryCount - 1, - file: file, - line: line) + return try await uploadURLSessionData( + genbaNeko: genbaNeko, + denwaNeko: denwaNeko, + message: message, + retryCount: retryCount - 1, + file: file, + line: line + ) } } @@ -46,21 +48,25 @@ extension XCTestCase { var request = URLRequest(url: URL(string: "https://localhost/upload")!) request.httpMethod = "POST" request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type") - let requestBody = createBody(boundary: boundary, - genbaNeko: genbaNeko, - denwaNeko: denwaNeko, - message: message) + let requestBody = createBody( + boundary: boundary, + genbaNeko: genbaNeko, + denwaNeko: denwaNeko, + message: message + ) do { let (data, _) = try await session.upload(for: request, from: requestBody) return try JSONDecoder().decode(TestEntity.self, from: data) } catch { guard retryCount > 0 else { throw error } - return try await uploadURLSessionUpload(genbaNeko: genbaNeko, - denwaNeko: denwaNeko, - message: message, - retryCount: retryCount - 1, - file: file, - line: line) + return try await uploadURLSessionUpload( + genbaNeko: genbaNeko, + denwaNeko: denwaNeko, + message: message, + retryCount: retryCount - 1, + file: file, + line: line + ) } } } @@ -87,10 +93,12 @@ extension XCTestCase { } } -private func createBody(boundary: String, - genbaNeko: Data, - denwaNeko: Data, - message: Data) -> Data { +private func createBody( + boundary: String, + genbaNeko: Data, + denwaNeko: Data, + message: Data +) -> Data { [ Data("--\(boundary)\r\n".utf8), Data("Content-Disposition: form-data; name=\"genbaNeko\"; filename=\"genbaNeko\"\r\n".utf8), diff --git a/Tests/MultipartFormDataParserTests/_Util/StubURLProtocol.swift b/Tests/MultipartFormDataParserTests/_Util/StubURLProtocol.swift index e97d37a..e249ec9 100644 --- a/Tests/MultipartFormDataParserTests/_Util/StubURLProtocol.swift +++ b/Tests/MultipartFormDataParserTests/_Util/StubURLProtocol.swift @@ -20,9 +20,11 @@ final class StubURLProtocol: URLProtocol { guard let requestHandler = Self.requestHandler else { return } do { let (data, response) = try requestHandler(request) - client?.urlProtocol(self, - didReceive: response, - cacheStoragePolicy: .notAllowed) + client?.urlProtocol( + self, + didReceive: response, + cacheStoragePolicy: .notAllowed + ) if let data { client?.urlProtocol(self, didLoad: data) } diff --git a/Tests/MultipartFormDataParserTests/_Util/TestStub.swift b/Tests/MultipartFormDataParserTests/_Util/TestStub.swift index 1b826e1..9f35904 100644 --- a/Tests/MultipartFormDataParserTests/_Util/TestStub.swift +++ b/Tests/MultipartFormDataParserTests/_Util/TestStub.swift @@ -25,10 +25,12 @@ private let uploadTestStubResponse: StubURLProtocol.RequestHandler = { request i let errorResponse = { (message: String) -> (Data?, HTTPURLResponse) in ( Data(#"{"status": 403, "error": "\#(message)"}"#.utf8), - HTTPURLResponse(url: request.url!, - statusCode: 403, - httpVersion: "HTTP/2", - headerFields: ["Content-Type": "application/json"])! + HTTPURLResponse( + url: request.url!, + statusCode: 403, + httpVersion: "HTTP/2", + headerFields: ["Content-Type": "application/json"] + )! ) } do { @@ -41,10 +43,12 @@ private let uploadTestStubResponse: StubURLProtocol.RequestHandler = { request i guard message.string == "Hello world!" else { return errorResponse("Unexpected message: \(message)") } return ( #"{"status": 200}"#.data(using: .utf8), - HTTPURLResponse(url: request.url!, - statusCode: 200, - httpVersion: "HTTP/2", - headerFields: ["Content-Type": "application/json"])! + HTTPURLResponse( + url: request.url!, + statusCode: 200, + httpVersion: "HTTP/2", + headerFields: ["Content-Type": "application/json"] + )! ) } catch { return errorResponse(error.localizedDescription)