@@ -79,10 +79,11 @@ class LambdaHandlerTest: XCTestCase {
79
79
assertLambdaLifecycleResult ( result, shoudHaveRun: maxTimes)
80
80
}
81
81
82
- #if compiler(>=5.5) && $AsyncAwait
82
+ #if compiler(>=5.5)
83
83
84
84
// MARK: - AsyncLambdaHandler
85
85
86
+ @available ( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * )
86
87
func testAsyncHandlerSuccess( ) {
87
88
let server = MockLambdaServer ( behavior: Behavior ( ) )
88
89
XCTAssertNoThrow ( try server. start ( ) . wait ( ) )
@@ -92,17 +93,20 @@ class LambdaHandlerTest: XCTestCase {
92
93
typealias In = String
93
94
typealias Out = String
94
95
96
+ init ( context: Lambda . InitializationContext ) { }
97
+
95
98
func handle( event: String , context: Lambda . Context ) async throws -> String {
96
99
event
97
100
}
98
101
}
99
102
100
103
let maxTimes = Int . random ( in: 1 ... 10 )
101
104
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 )
103
106
assertLambdaLifecycleResult ( result, shoudHaveRun: maxTimes)
104
107
}
105
108
109
+ @available ( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * )
106
110
func testVoidAsyncHandlerSuccess( ) {
107
111
let server = MockLambdaServer ( behavior: Behavior ( result: . success( nil ) ) )
108
112
XCTAssertNoThrow ( try server. start ( ) . wait ( ) )
@@ -112,15 +116,18 @@ class LambdaHandlerTest: XCTestCase {
112
116
typealias In = String
113
117
typealias Out = Void
114
118
119
+ init ( context: Lambda . InitializationContext ) { }
120
+
115
121
func handle( event: String , context: Lambda . Context ) async throws { }
116
122
}
117
123
118
124
let maxTimes = Int . random ( in: 1 ... 10 )
119
125
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 )
121
127
assertLambdaLifecycleResult ( result, shoudHaveRun: maxTimes)
122
128
}
123
129
130
+ @available ( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * )
124
131
func testAsyncHandlerFailure( ) {
125
132
let server = MockLambdaServer ( behavior: Behavior ( result: . failure( TestError ( " boom " ) ) ) )
126
133
XCTAssertNoThrow ( try server. start ( ) . wait ( ) )
@@ -130,14 +137,16 @@ class LambdaHandlerTest: XCTestCase {
130
137
typealias In = String
131
138
typealias Out = String
132
139
140
+ init ( context: Lambda . InitializationContext ) { }
141
+
133
142
func handle( event: String , context: Lambda . Context ) async throws -> String {
134
143
throw TestError ( " boom " )
135
144
}
136
145
}
137
146
138
147
let maxTimes = Int . random ( in: 1 ... 10 )
139
148
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 )
141
150
assertLambdaLifecycleResult ( result, shoudHaveRun: maxTimes)
142
151
}
143
152
#endif
0 commit comments