-
Notifications
You must be signed in to change notification settings - Fork 389
How to write a test for query_string_parameters #252
Copy link
Copy link
Closed
Description
I want to write a test for example: https://github.com/awslabs/aws-lambda-rust-runtime/blob/a9de2fcb24030a00e402348aba3c368b717feb6d/lambda-http/examples/hello-http-without-macros.rs#L15-L23
But until now it does not work.
#[cfg(test)]
mod tests {
use super::*;
use lambda_http::http::StatusCode;
use lambda_http::{http, Body};
#[tokio::test]
async fn main_handles() {
let request = http::Request::builder()
.uri("https://api.com/?first_name=John")
.expect("failed to build request");
let expected = json!({"first_name": "John"}).into_response();
let response = func(request, Context::default())
.await
.expect("expected Ok(_) value")
.into_response();
assert_eq!(response.body(), expected.body());
assert_eq!(response.status(), StatusCode::OK)
}
}How can I stub the request?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels