Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example Tide unit test in Rust, with a Request and checked Response
#[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