Is that possible to write intergration test?
AWS Lambda provides such support, but I didn't know how to implement it with vercel runtime
Hi @Zxilly, can you link to the documentation of what this would mean, in the context of AWS Lambda?
https://github.com/awslabs/aws-lambda-rust-runtime/tree/main?tab=readme-ov-file#local-development-and-testing
I want to mock a request and ensure the response met the requirement.
Thanks for linking that. The same logic applies - your handler function in the Vercel runtime world is simply an async fn, so it can be called in a #[test] the same way any other function can.
I want something like
#[test]
fn test_my_lambda_handler() {
let input = include_str!("apigw_proxy_request.json");
let request = lambda_http::request::from_str(input)
.expect("failed to create request");
let response = my_lambda_handler(request).await.expect("failed to handle request");
}
Is that also possible right now?
I don't think the from_str part is exposed at the moment, so there's no super convenient way to achieve what you're attempting to there.
CC @ecklf we might want to consider exposing the Request::builder APIs or similar 🤔