Skip to content

Commit 4c85713

Browse files
committed
final fixes
1 parent 67c9d72 commit 4c85713

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

Sources/AWSLambdaTesting/Lambda+Testing.swift

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,52 +39,51 @@ extension Lambda {
3939
public static func test(_ closure: @escaping StringLambdaClosure,
4040
with payload: String,
4141
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)
4343
}
4444

4545
public static func test(_ closure: @escaping StringVoidLambdaClosure,
4646
with payload: String,
4747
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)
4949
}
5050

5151
public static func test<In: Decodable, Out: Encodable>(
5252
_ closure: @escaping CodableLambdaClosure<In, Out>,
5353
with payload: In,
5454
using config: TestConfig = .init()
5555
) throws -> Out {
56-
try Self.test(CodableLambdaClosureWrapper(closure), config: config, with: payload)
56+
try Self.test(CodableLambdaClosureWrapper(closure), with: payload, using: config)
5757
}
5858

5959
public static func test<In: Decodable>(
6060
_ closure: @escaping CodableVoidLambdaClosure<In>,
6161
with payload: In,
6262
using config: TestConfig = .init()
6363
) throws {
64-
_ = try Self.test(CodableVoidLambdaClosureWrapper(closure), config: config, with: payload)
64+
_ = try Self.test(CodableVoidLambdaClosureWrapper(closure), with: payload, using: config)
6565
}
6666

6767
public static func test<In, Out, Handler: EventLoopLambdaHandler>(
6868
_ handler: Handler,
69-
config: TestConfig = .init(),
70-
with payload: In
69+
with payload: In,
70+
using config: TestConfig = .init()
7171
) throws -> Out where Handler.In == In, Handler.Out == Out {
7272
let logger = Logger(label: "test")
7373
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
74+
defer {
75+
try! eventLoopGroup.syncShutdownGracefully()
76+
}
7477
let eventLoop = eventLoopGroup.next()
75-
7678
let context = Context(requestId: config.requestId,
7779
traceId: config.traceId,
7880
invokedFunctionArn: config.invokedFunctionArn,
7981
deadline: .now() + config.timeout,
8082
logger: logger,
8183
eventLoop: eventLoop)
8284

83-
let result = try eventLoop.flatSubmit {
85+
return try eventLoop.flatSubmit {
8486
handler.handle(context: context, payload: payload)
8587
}.wait()
86-
87-
try eventLoopGroup.syncShutdownGracefully()
88-
return result
8988
}
9089
}

0 commit comments

Comments
 (0)