Fix tests/wildcard#518
Merged
yoshuawuyts merged 18 commits intohttp-rs:masterfrom May 29, 2020
yusuke-ota:fix_test_wildcard
Merged
Fix tests/wildcard#518yoshuawuyts merged 18 commits intohttp-rs:masterfrom yusuke-ota:fix_test_wildcard
yoshuawuyts merged 18 commits intohttp-rs:masterfrom
yusuke-ota:fix_test_wildcard
Conversation
jbr
reviewed
May 23, 2020
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"); |
Member
There was a problem hiding this comment.
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");
Contributor
Author
tests/wildcard.rs
Outdated
| use tide::{http, Request}; | ||
|
|
||
| async fn add_one(cx: Request<()>) -> Result<String, tide::Error> { | ||
| return match cx.param::<i64>("num") { |
Contributor
Author
There was a problem hiding this comment.
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") { |
Member
There was a problem hiding this comment.
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 ?
Contributor
Author
There was a problem hiding this comment.
Thank you for review.
This corrected at af3b75f.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.