File tree Expand file tree Collapse file tree 2 files changed +13
-15
lines changed
Tests/AWSLambdaEventsTests Expand file tree Collapse file tree 2 files changed +13
-15
lines changed Original file line number Diff line number Diff line change 1212//
1313//===----------------------------------------------------------------------===//
1414
15+ import HTTPTypes
16+
1517#if canImport(FoundationEssentials)
1618import class FoundationEssentials. JSONEncoder
1719import class FoundationEssentials. Data
@@ -20,15 +22,13 @@ import class Foundation.JSONEncoder
2022import struct Foundation. Data
2123#endif
2224
23- import HTTPTypes
24-
2525public enum APIGatewayResponseError : Error {
2626 case failedToEncodeBody( Error )
2727}
2828
2929extension APIGatewayV2Response {
3030
31- public init < Input: Encodable > (
31+ public init < Input: Encodable > (
3232 statusCode: HTTPResponse . Status ,
3333 headers: HTTPHeaders ? = nil ,
3434 body: Input ,
Original file line number Diff line number Diff line change 1212//
1313//===----------------------------------------------------------------------===//
1414
15+ import Foundation
1516import Testing
1617
17- import Foundation
18-
1918@testable import AWSLambdaEvents
2019
2120struct APIGatewayV2EncodableResponseTests {
2221
23-
2422 // MARK: Encoding
2523 struct BusinessResponse : Codable , Equatable {
2624 let message : String
2725 let code : Int
2826 }
2927
30- @Test
28+ @Test
3129 func testResponseEncoding( ) throws {
3230
33- // given
31+ // given
3432 let businessResponse = BusinessResponse ( message: " Hello World " , code: 200 )
35-
33+
3634 var response : APIGatewayV2Response ? = nil
37- #expect( throws: Never . self) {
35+ #expect( throws: Never . self) {
3836 try response = APIGatewayV2Response ( statusCode: . ok, body: businessResponse)
39- }
37+ }
4038 try #require( response? . body != nil )
4139
42- // when
43- let body = response? . body? . data ( using: . utf8)
40+ // when
41+ let body = response? . body? . data ( using: . utf8)
4442 try #require( body != nil )
4543
46- #expect( throws: Never . self) {
44+ #expect( throws: Never . self) {
4745 let encodedBody = try JSONDecoder ( ) . decode ( BusinessResponse . self, from: body!)
48-
46+
4947 // then
5048 #expect( encodedBody == businessResponse)
5149 }
You can’t perform that action at this time.
0 commit comments