Skip to content

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

Merged
merged 7 commits into from
Apr 23, 2020
Merged

Improve testing utils #60

merged 7 commits into from
Apr 23, 2020

Conversation

fabianfett
Copy link
Member

No description provided.

@fabianfett fabianfett force-pushed the feature/testing-harness-sync branch from ed689e1 to a731c23 Compare April 22, 2020 15:09
@fabianfett fabianfett changed the title Some improvements Improve testing utils Apr 22, 2020
@fabianfett fabianfett force-pushed the feature/testing-harness-sync branch 2 times, most recently from 6999f24 to ea667ec Compare April 22, 2020 15:43
handler.handle(context: context, payload: payload)
}.wait()

try eventLoopGroup.syncShutdownGracefully()
Copy link
Contributor

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

Copy link
Member Author

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?

Copy link
Member Author

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?

Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DispatchTimeInterval

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@tomerd tomerd left a 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tomerd tomerd requested a review from tachyonics April 22, 2020 21:34
@fabianfett fabianfett changed the base branch from feature/testing-harness to master April 22, 2020 23:10

public static func test<In, Out, Handler: EventLoopLambdaHandler>(
_ handler: Handler,
config: TestConfig = .init(),
Copy link
Member Author

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.

tomerd and others added 4 commits April 23, 2020 08:28
motivation: make testing lambda easy

changes:
* add a AWSLambdaTesting module
* add helper methods for testing different types of Lambda handlers / closures
@fabianfett fabianfett force-pushed the feature/testing-harness-sync branch from 74819b7 to 4c85713 Compare April 23, 2020 06:32
fabianfett and others added 3 commits April 23, 2020 09:07
Co-Authored-By: tomer doron <tomerd@apple.com>
Co-Authored-By: tomer doron <tomerd@apple.com>
Co-Authored-By: tomer doron <tomerd@apple.com>
@tomerd tomerd merged commit 920302a into master Apr 23, 2020
@fabianfett fabianfett deleted the feature/testing-harness-sync branch April 23, 2020 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants