Closed saltzmanjoelh closed 3 years ago
I'm firing up the local server in some tests.
how are you doing that?
note there is also AWSLambdaTesting
module designed to help with unit tests without a full server
Sorry, I should have described that. I'm firing up the local lambda server.
As I'm describing my setup, I'm realizing that I should be breaking my code up a bit more to test the specific pieces of code. Thanks for the AWSLambdaTesting reference. I will take a look.
public static func main() {
#if DEBUG && os(macOS)
setenv("LOCAL_LAMBDA_SERVER_ENABLED", "true", 1)
#endif
// Initialize some immutable vars used in the callback
Lambda.run { (context: Lambda.Context, request: APIGateway.V2.Request, callback: @escaping (Result<APIGateway.V2.Response, Error>) -> Void) in
// Handle request and call the callback
}
}
I'm firing up the local server in some tests. Is there a way to gracefully shut it down between tests or at the end of the XCTestCase?
I read that it can handle a TERM signal but I'm not sure how to send it directly to the local server and instead of the XCTest that is running.