Skip to content
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

Is that possible to write intergration test? #118

Open
Zxilly opened this issue Aug 28, 2023 · 5 comments
Open

Is that possible to write intergration test? #118

Zxilly opened this issue Aug 28, 2023 · 5 comments

Comments

@Zxilly
Copy link
Contributor

Zxilly commented Aug 28, 2023

AWS Lambda provides such support, but I didn't know how to implement it with vercel runtime

@dglsparsons
Copy link
Collaborator

Hi @Zxilly, can you link to the documentation of what this would mean, in the context of AWS Lambda?

@Zxilly
Copy link
Contributor Author

Zxilly commented Aug 28, 2023

@Zxilly Zxilly changed the title Is that possible to write intergrated test? Is that possible to write intergration test? Aug 28, 2023
@dglsparsons
Copy link
Collaborator

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.

@Zxilly
Copy link
Contributor Author

Zxilly commented Aug 28, 2023

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?

@dglsparsons
Copy link
Collaborator

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 🤔

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

No branches or pull requests

2 participants