-
Notifications
You must be signed in to change notification settings - Fork 322
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
Fix tests/wildcard #518
Fix tests/wildcard #518
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
tests/wildcard.rs
Outdated
let mut res: http::Response = app.respond(req).await.unwrap(); | ||
assert_eq!(res.status(), StatusCode::Ok); | ||
let body = res.take_body().into_string().await.unwrap(); | ||
assert_eq!(body.as_bytes(), b"4"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead taking the body and converting it into a string and then into bytes, these assertions can be made more concise with
assert_eq!(&res.body_string().await.unwrap(), "4");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/wildcard.rs
Outdated
use tide::{http, Request}; | ||
|
||
async fn add_one(cx: Request<()>) -> Result<String, tide::Error> { | ||
return match cx.param::<i64>("num") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this return
keyword necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for review.
This corrected at 070fbe1.
tests/wildcard.rs
Outdated
|
||
async fn add_two(cx: Request<()>) -> Result<String, tide::Error> { | ||
let one; | ||
match cx.param::<i64>("one") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might read more idiomatically if one
and two
were returned by the match expression instead of assigned inside of the match expression, and the error early-returning could might be accomplished with a .map_err
and a ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for review.
This corrected at af3b75f.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Fix test/wildcard.rs
This PR is related to #509
This file used Crate "http_service" and "http_service_mock".
But Cargo.toml does not contain them.
So, I use "Request::new(Method::Get, "http://localhost/*")" and "Server::respond(req)" instead of them.