blob: 406c45f08a57ef02b87f4143b54191b15e784919 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
use askama::Template;
use poem::{handler, test::TestClient, Route};
#[derive(Template)]
#[template(path = "hello.html")]
struct HelloTemplate<'a> {
name: &'a str,
}
#[handler]
fn hello() -> HelloTemplate<'static> {
HelloTemplate { name: "world" }
}
#[tokio::test]
async fn test_poem() {
let app = Route::new().at("/", hello);
let cli = TestClient::new(app);
let resp = cli.get("/").send().await;
resp.assert_status_is_ok();
resp.assert_text("Hello, world!").await;
}
|