use poem::IntoResponse;
use poem::Route;
use poem::get;
use poem::handler;
use poem::web::Html;

#[handler]
async fn hello() -> impl IntoResponse {
    Html("ok")
}

pub fn create_app() -> Route {
    Route::new().at("hello/", get(hello))
}

#[cfg(test)]
mod test {
    use poem::test::TestClient;

    use super::*;

    #[tokio::test]
    async fn hello_returns_ok() {
        let app = create_app();
        let cli = TestClient::new(app);
        let resp = cli.get("/hello/").send().await;

        resp.assert_status_is_ok();

        resp.assert_text("ok").await;
    }
}
