@@ -17,14 +17,14 @@ import NIOEmbedded
1717import NIOHTTP1
1818import Testing
1919
20+ @testable import AWSLambdaRuntime
21+
2022#if canImport(FoundationEssentials)
2123import FoundationEssentials
2224#else
2325import Foundation
2426#endif
2527
26- @testable import AWSLambdaRuntime
27-
2828struct ControlPlaneRequestEncoderTests {
2929 let host = " 192.168.0.1 "
3030
@@ -44,7 +44,7 @@ struct ControlPlaneRequestEncoderTests {
4444 _ = try ? client. finish ( acceptAlreadyClosed: false )
4545 _ = try ? server. finish ( acceptAlreadyClosed: false )
4646 }
47-
47+
4848 let request = try sendRequest ( . next, client: client, server: server)
4949
5050 #expect( request? . head. isKeepAlive == true )
@@ -64,7 +64,7 @@ struct ControlPlaneRequestEncoderTests {
6464 _ = try ? client. finish ( acceptAlreadyClosed: false )
6565 _ = try ? server. finish ( acceptAlreadyClosed: false )
6666 }
67-
67+
6868 let requestID = UUID ( ) . uuidString
6969 let request = try sendRequest ( . invocationResponse( requestID, nil ) , client: client, server: server)
7070
@@ -86,7 +86,7 @@ struct ControlPlaneRequestEncoderTests {
8686 _ = try ? client. finish ( acceptAlreadyClosed: false )
8787 _ = try ? server. finish ( acceptAlreadyClosed: false )
8888 }
89-
89+
9090 let requestID = UUID ( ) . uuidString
9191 let payload = ByteBuffer ( string: " hello swift lambda! " )
9292
@@ -111,7 +111,7 @@ struct ControlPlaneRequestEncoderTests {
111111 _ = try ? client. finish ( acceptAlreadyClosed: false )
112112 _ = try ? server. finish ( acceptAlreadyClosed: false )
113113 }
114-
114+
115115 let requestID = UUID ( ) . uuidString
116116 let error = ErrorResponse ( errorType: " SomeError " , errorMessage: " An error happened " )
117117 let request = try sendRequest ( . invocationError( requestID, error) , client: client, server: server)
@@ -139,7 +139,7 @@ struct ControlPlaneRequestEncoderTests {
139139 _ = try ? client. finish ( acceptAlreadyClosed: false )
140140 _ = try ? server. finish ( acceptAlreadyClosed: false )
141141 }
142-
142+
143143 let error = ErrorResponse ( errorType: " StartupError " , errorMessage: " Urgh! Startup failed. 😨 " )
144144 let request = try sendRequest ( . initializationError( error) , client: client, server: server)
145145
@@ -165,21 +165,29 @@ struct ControlPlaneRequestEncoderTests {
165165 _ = try ? client. finish ( acceptAlreadyClosed: false )
166166 _ = try ? server. finish ( acceptAlreadyClosed: false )
167167 }
168-
168+
169169 for _ in 0 ..< 1000 {
170170 let nextRequest = try sendRequest ( . next, client: client, server: server)
171171 #expect( nextRequest? . head. method == . GET)
172172 #expect( nextRequest? . head. uri == " /2018-06-01/runtime/invocation/next " )
173173
174174 let requestID = UUID ( ) . uuidString
175175 let payload = ByteBuffer ( string: " hello swift lambda! " )
176- let successRequest = try sendRequest ( . invocationResponse( requestID, payload) , client: client, server: server)
176+ let successRequest = try sendRequest (
177+ . invocationResponse( requestID, payload) ,
178+ client: client,
179+ server: server
180+ )
177181 #expect( successRequest? . head. method == . POST)
178182 #expect( successRequest? . head. uri == " /2018-06-01/runtime/invocation/ \( requestID) /response " )
179183 }
180184 }
181185
182- func sendRequest( _ request: ControlPlaneRequest , client: EmbeddedChannel , server: EmbeddedChannel ) throws -> NIOHTTPServerRequestFull ? {
186+ func sendRequest(
187+ _ request: ControlPlaneRequest ,
188+ client: EmbeddedChannel ,
189+ server: EmbeddedChannel
190+ ) throws -> NIOHTTPServerRequestFull ? {
183191 try client. writeOutbound ( request)
184192 while let part = try client. readOutbound ( as: ByteBuffer . self) {
185193 try server. writeInbound ( part)
0 commit comments