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

[test] the hello-world example #3264

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

szabgab
Copy link

@szabgab szabgab commented Mar 12, 2025

See #3263

@yanns
Copy link
Collaborator

yanns commented Mar 12, 2025

Does this test really provides value?
In my opinion, a test sending a HTTP request to the app and checking the http response would provide more value.
You can use

#[tokio::test]
async fn handle_uncompressed_request_bodies() {
// Given
let body = json();
let compressed_request = http::Request::post("/")
.header(header::CONTENT_TYPE, "application/json")
.body(json_body(&body))
.unwrap();
// When
let response = app().oneshot(compressed_request).await.unwrap();
// Then
assert_eq!(response.status(), StatusCode::OK);
assert_json_eq!(json_from_response(response).await, json());
}
as an example of such test.

@szabgab
Copy link
Author

szabgab commented Mar 12, 2025

If I am not mistaken for that I'll have to create the app function and move the Router creation there. I think that would be the better way to do this but I was not sure if that is desirable in this most basic "Hello World" example.

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