@@ -39,52 +39,51 @@ extension Lambda {
39
39
public static func test( _ closure: @escaping StringLambdaClosure ,
40
40
with payload: String ,
41
41
using config: TestConfig = . init( ) ) throws -> String {
42
- try Self . test ( StringLambdaClosureWrapper ( closure) , config : config , with : payload )
42
+ try Self . test ( StringLambdaClosureWrapper ( closure) , with : payload , using : config )
43
43
}
44
44
45
45
public static func test( _ closure: @escaping StringVoidLambdaClosure ,
46
46
with payload: String ,
47
47
using config: TestConfig = . init( ) ) throws {
48
- _ = try Self . test ( StringVoidLambdaClosureWrapper ( closure) , config : config , with : payload )
48
+ _ = try Self . test ( StringVoidLambdaClosureWrapper ( closure) , with : payload , using : config )
49
49
}
50
50
51
51
public static func test< In: Decodable , Out: Encodable > (
52
52
_ closure: @escaping CodableLambdaClosure < In , Out > ,
53
53
with payload: In ,
54
54
using config: TestConfig = . init( )
55
55
) throws -> Out {
56
- try Self . test ( CodableLambdaClosureWrapper ( closure) , config : config , with : payload )
56
+ try Self . test ( CodableLambdaClosureWrapper ( closure) , with : payload , using : config )
57
57
}
58
58
59
59
public static func test< In: Decodable > (
60
60
_ closure: @escaping CodableVoidLambdaClosure < In > ,
61
61
with payload: In ,
62
62
using config: TestConfig = . init( )
63
63
) throws {
64
- _ = try Self . test ( CodableVoidLambdaClosureWrapper ( closure) , config : config , with : payload )
64
+ _ = try Self . test ( CodableVoidLambdaClosureWrapper ( closure) , with : payload , using : config )
65
65
}
66
66
67
67
public static func test< In, Out, Handler: EventLoopLambdaHandler > (
68
68
_ handler: Handler ,
69
- config : TestConfig = . init ( ) ,
70
- with payload : In
69
+ with payload : In ,
70
+ using config : TestConfig = . init ( )
71
71
) throws -> Out where Handler. In == In , Handler. Out == Out {
72
72
let logger = Logger ( label: " test " )
73
73
let eventLoopGroup = MultiThreadedEventLoopGroup ( numberOfThreads: 1 )
74
+ defer {
75
+ try ! eventLoopGroup. syncShutdownGracefully ( )
76
+ }
74
77
let eventLoop = eventLoopGroup. next ( )
75
-
76
78
let context = Context ( requestId: config. requestId,
77
79
traceId: config. traceId,
78
80
invokedFunctionArn: config. invokedFunctionArn,
79
81
deadline: . now( ) + config. timeout,
80
82
logger: logger,
81
83
eventLoop: eventLoop)
82
84
83
- let result = try eventLoop. flatSubmit {
85
+ return try eventLoop. flatSubmit {
84
86
handler. handle ( context: context, payload: payload)
85
87
} . wait ( )
86
-
87
- try eventLoopGroup. syncShutdownGracefully ( )
88
- return result
89
88
}
90
89
}
0 commit comments