#![allow(unused)]
fn main() {
use super::*;
use axum::{
body::Body,
http::{Request, StatusCode},
};
use http_body_util::BodyExt;
use tower::ServiceExt;
#[tokio::test]
async fn test_main() {
let response = create_router()
.oneshot(Request::builder().uri("/").body(Body::empty()).unwrap())
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK);
let content_type = response.headers().get("content-type").unwrap();
assert_eq!(content_type.to_str().unwrap(), "text/html; charset=utf-8");
let body = response.into_body();
let bytes = body.collect().await.unwrap().to_bytes();
let html = String::from_utf8(bytes.to_vec()).unwrap();
assert!(html.contains(r#"<h1>Planets</h1>"#));
}
}
<h1>Planets</h1>
<table>
{% for planet in planets %}
<tr><td>{{planet.name}}</td><td>{{planet.distance}}</td><td>{{planet.mass}}</td></tr>
{% endfor %}
</table>
<style>
td {
padding: 10px;
}
</style>