-
Notifications
You must be signed in to change notification settings - Fork 113
Improve testing utils #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ed689e1
to
a731c23
Compare
6999f24
to
ea667ec
Compare
handler.handle(context: context, payload: payload) | ||
}.wait() | ||
|
||
try eventLoopGroup.syncShutdownGracefully() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use defer and move to L73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use defer
we have to do something with the try... that's why i moved it here. Neither wanted to try!
nor try?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomerd What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think try! in the defer is fine, or you can try/catch in the defer and print something too
@@ -75,19 +64,32 @@ class LambdaTestingTests: XCTestCase { | |||
typealias Out = Response | |||
|
|||
func handle(context: Lambda.Context, payload: In, callback: @escaping (Result<Out, Error>) -> Void) { | |||
XCTAssertFalse(context.eventLoop.inEventLoop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
typealias Out = String | ||
|
||
func handle(context: Lambda.Context, payload: String) -> EventLoopFuture<String> { | ||
XCTAssertTrue(context.eventLoop.inEventLoop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
public var requestId: String | ||
public var traceId: String | ||
public var invokedFunctionArn: String | ||
public var timeout: Double |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DispatchTimeInterval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is much better than my version <3 few small comments
} | ||
eventLoop: eventLoop) | ||
|
||
let result = try eventLoop.flatSubmit { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
public static func test<In, Out, Handler: EventLoopLambdaHandler>( | ||
_ handler: Handler, | ||
config: TestConfig = .init(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Urgh. I have overseen this buddy.
motivation: make testing lambda easy changes: * add a AWSLambdaTesting module * add helper methods for testing different types of Lambda handlers / closures
74819b7
to
4c85713
Compare
Co-Authored-By: tomer doron <tomerd@apple.com>
Co-Authored-By: tomer doron <tomerd@apple.com>
Co-Authored-By: tomer doron <tomerd@apple.com>
No description provided.