@@ -79,10 +79,11 @@ class LambdaHandlerTest: XCTestCase {
7979 assertLambdaLifecycleResult ( result, shoudHaveRun: maxTimes)
8080 }
8181
82- #if compiler(>=5.5) && $AsyncAwait
82+ #if compiler(>=5.5)
8383
8484 // MARK: - AsyncLambdaHandler
8585
86+ @available ( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * )
8687 func testAsyncHandlerSuccess( ) {
8788 let server = MockLambdaServer ( behavior: Behavior ( ) )
8889 XCTAssertNoThrow ( try server. start ( ) . wait ( ) )
@@ -92,17 +93,20 @@ class LambdaHandlerTest: XCTestCase {
9293 typealias In = String
9394 typealias Out = String
9495
96+ init ( context: Lambda . InitializationContext ) { }
97+
9598 func handle( event: String , context: Lambda . Context ) async throws -> String {
9699 event
97100 }
98101 }
99102
100103 let maxTimes = Int . random ( in: 1 ... 10 )
101104 let configuration = Lambda . Configuration ( lifecycle: . init( maxTimes: maxTimes) )
102- let result = Lambda . run ( configuration: configuration, handler : Handler ( ) )
105+ let result = Lambda . run ( configuration: configuration, factory : Handler . init )
103106 assertLambdaLifecycleResult ( result, shoudHaveRun: maxTimes)
104107 }
105108
109+ @available ( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * )
106110 func testVoidAsyncHandlerSuccess( ) {
107111 let server = MockLambdaServer ( behavior: Behavior ( result: . success( nil ) ) )
108112 XCTAssertNoThrow ( try server. start ( ) . wait ( ) )
@@ -112,15 +116,18 @@ class LambdaHandlerTest: XCTestCase {
112116 typealias In = String
113117 typealias Out = Void
114118
119+ init ( context: Lambda . InitializationContext ) { }
120+
115121 func handle( event: String , context: Lambda . Context ) async throws { }
116122 }
117123
118124 let maxTimes = Int . random ( in: 1 ... 10 )
119125 let configuration = Lambda . Configuration ( lifecycle: . init( maxTimes: maxTimes) )
120- let result = Lambda . run ( configuration: configuration, handler : Handler ( ) )
126+ let result = Lambda . run ( configuration: configuration, factory : Handler . init )
121127 assertLambdaLifecycleResult ( result, shoudHaveRun: maxTimes)
122128 }
123129
130+ @available ( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * )
124131 func testAsyncHandlerFailure( ) {
125132 let server = MockLambdaServer ( behavior: Behavior ( result: . failure( TestError ( " boom " ) ) ) )
126133 XCTAssertNoThrow ( try server. start ( ) . wait ( ) )
@@ -130,14 +137,16 @@ class LambdaHandlerTest: XCTestCase {
130137 typealias In = String
131138 typealias Out = String
132139
140+ init ( context: Lambda . InitializationContext ) { }
141+
133142 func handle( event: String , context: Lambda . Context ) async throws -> String {
134143 throw TestError ( " boom " )
135144 }
136145 }
137146
138147 let maxTimes = Int . random ( in: 1 ... 10 )
139148 let configuration = Lambda . Configuration ( lifecycle: . init( maxTimes: maxTimes) )
140- let result = Lambda . run ( configuration: configuration, handler : Handler ( ) )
149+ let result = Lambda . run ( configuration: configuration, factory : Handler . init )
141150 assertLambdaLifecycleResult ( result, shoudHaveRun: maxTimes)
142151 }
143152 #endif
0 commit comments