-
Notifications
You must be signed in to change notification settings - Fork 44
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
refactor tests #157
refactor tests #157
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.
Overall much better, a few comments
tests/client_decode.rs
Outdated
use pretty_assertions::assert_eq; | ||
|
||
async fn decode_str(s: &'static str) -> http_types::Result<http_types::Response> { | ||
client::decode(Cursor::new(s.replace("\n", "\r\n"))).await |
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.
It may be easier to read these raw strings if they are e.g.
vec![
"HTTP/1.1 200 OK",
"transfer-encoding: chunked",
"content-type: text/plain",
"",
"",
];
with some kind of map(|s| s.append("\r\n")
and then a join("")
.
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.
what do you think about https://github.com/dtolnay/indoc
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.
Hmm, better, although the trailing linebreaks (and any special white space) may become less clear?
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.
wasn't sure about this, but i think it ended up an improvement, which strikes me as a language issue: 59caa84
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.
These changes are really good! -- Added a few comments, but overall 💯
@@ -0,0 +1,67 @@ | |||
mod client_decode { |
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 doesn't need a surrounding mod
; it wraps tests out of the box already.
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.
@yoshuawuyts I know these aren't necessary but I like that I can type cargo test client_decode
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.
(without the extra mod client_decode {
line, it doesn't seem work to type cargo test client_decode
)
@@ -0,0 +1,178 @@ | |||
mod client_encode { |
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 doesn't need a surrounding mod
; it wraps tests out of the box already.
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.
as above, this isn't for rustc, it's so i can type cargo test client_encode
and run all of the tests in this module
@@ -0,0 +1,127 @@ | |||
mod server_decode { |
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 doesn't need a surrounding mod
; it wraps tests out of the box already.
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.
as mentioned above, this for convenience of running just one set of tests — I use these like describe
in other testing frameworks
@@ -0,0 +1,167 @@ | |||
mod server_encode { |
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 doesn't need a surrounding mod
; it wraps tests out of the box already.
this eliminates the file based TestCase and instead provides strings for locality of reference — it's a lot easier to understand what the test is doing if the request or response content is right in the test. this also splits tests out into client/server x encode/decode