@@ -20,7 +20,7 @@ import Testing
2020@testable import OpenAPILambda
2121
2222struct ALBConversionTests {
23-
23+
2424 static let albEventJSON = """
2525 {
2626 " requestContext " : {
@@ -40,21 +40,27 @@ struct ALBConversionTests {
4040 " isBase64Encoded " : false
4141 }
4242 """
43-
43+
4444 @Test ( " ALB request to HTTPRequest conversion " )
4545 func testALBRequestToHTTPRequest( ) throws {
4646 let data = ALBConversionTests . albEventJSON. data ( using: . utf8) !
4747 let albRequest = try JSONDecoder ( ) . decode ( ALBTargetGroupRequest . self, from: data)
48-
48+
4949 let httpRequest = try albRequest. httpRequest ( )
50-
50+
5151 #expect( httpRequest. method == HTTPRequest . Method. get)
5252 #expect( httpRequest. path == " /stocks/AAPL " )
53- #expect( httpRequest. headerFields [ HTTPField . Name. accept] == " text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 " )
53+ #expect(
54+ httpRequest. headerFields [ HTTPField . Name. accept]
55+ == " text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 "
56+ )
5457 #expect( httpRequest. headerFields [ HTTPField . Name ( " host " ) !] == " lambda-alb-123578498.us-east-1.elb.amazonaws.com " )
55- #expect( httpRequest. headerFields [ HTTPField . Name. userAgent] == " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " )
58+ #expect(
59+ httpRequest. headerFields [ HTTPField . Name. userAgent]
60+ == " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
61+ )
5662 }
57-
63+
5864 @Test ( " ALB X-Forwarded-Proto and Host mapping " )
5965 func testALBForwardedHeaders( ) throws {
6066 let albEventWithForwardedHeaders = """
@@ -75,16 +81,16 @@ struct ALBConversionTests {
7581 " isBase64Encoded " : false
7682 }
7783 """
78-
84+
7985 let data = albEventWithForwardedHeaders. data ( using: . utf8) !
8086 let albRequest = try JSONDecoder ( ) . decode ( ALBTargetGroupRequest . self, from: data)
81-
87+
8288 let httpRequest = try albRequest. httpRequest ( )
83-
89+
8490 #expect( httpRequest. scheme == " https " )
8591 #expect( httpRequest. authority == " lambda-alb-123578498.us-east-1.elb.amazonaws.com " )
8692 }
87-
93+
8894 @Test ( " ALB lowercase headers mapping " )
8995 func testALBLowercaseHeaders( ) throws {
9096 let albEventWithLowercaseHeaders = """
@@ -105,29 +111,29 @@ struct ALBConversionTests {
105111 " isBase64Encoded " : false
106112 }
107113 """
108-
114+
109115 let data = albEventWithLowercaseHeaders. data ( using: . utf8) !
110116 let albRequest = try JSONDecoder ( ) . decode ( ALBTargetGroupRequest . self, from: data)
111-
117+
112118 let httpRequest = try albRequest. httpRequest ( )
113-
119+
114120 #expect( httpRequest. scheme == " https " )
115121 #expect( httpRequest. authority == " lambda-alb-123578498.us-east-1.elb.amazonaws.com " )
116122 }
117-
123+
118124 @Test ( " HTTPResponse to ALB response conversion " )
119125 func testHTTPResponseToALBResponse( ) throws {
120126 var httpResponse = HTTPResponse ( status: . ok)
121127 httpResponse. headerFields [ HTTPField . Name. contentType] = " application/json "
122128 httpResponse. headerFields [ HTTPField . Name. contentLength] = " 42 "
123-
129+
124130 let albResponse = ALBTargetGroupResponse ( from: httpResponse)
125-
131+
126132 #expect( albResponse. statusCode == . ok)
127133 #expect( albResponse. headers ? [ HTTPField . Name. contentType. rawName] == " application/json " )
128134 #expect( albResponse. headers ? [ HTTPField . Name. contentLength. rawName] == " 42 " )
129135 #expect( albResponse. isBase64Encoded == false )
130136 }
131-
132137
133- }
138+
139+ }
0 commit comments