-
-
Save pepoviola/323630d87e2cf3bfc8b23717049aa5bd to your computer and use it in GitHub Desktop.
An example Tide unit test in Rust, with a Request and checked Response
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
#[cfg(test)] | |
mod tests { | |
#[async_std::test] | |
async fn index_page() -> tide::Result<()> { | |
use tide::http::{Url, Method, Request, Response}; | |
let mut app = tide::new(); | |
app.at("/").get(|_| async { Ok("Hello, world!") }); | |
let url = Url::parse("https://example.com").unwrap(); | |
let req = Request::new(Method::Get, url); | |
let mut res: Response = app.respond(req).await?; | |
assert_eq!("Hello, world", res.body_string().await?); | |
Ok(()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment