style: fix cargo fmt issues in pages.rs and root_landing_tests.rs
This commit is contained in:
1 parent
3c0a1bdd91
commit
02a26cfd94
2 files changed
+10
-8
No files matched your search
@@ -120,4 +120,3 @@ pub async fn root_landing() -> Response {
|
|||||||
Err(_) => (StatusCode::NOT_FOUND, "Not Found").into_response(),
|
Err(_) => (StatusCode::NOT_FOUND, "Not Found").into_response(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6,14 +6,19 @@ use std::fs;
|
|||||||
async fn test_root_landing_page() {
|
async fn test_root_landing_page() {
|
||||||
// --- Test case 1: Successful serving ---
|
// --- Test case 1: Successful serving ---
|
||||||
// Read expected content
|
// Read expected content
|
||||||
let expected_content = fs::read_to_string("www/index.html").expect("www/index.html must exist for test");
|
let expected_content =
|
||||||
|
fs::read_to_string("www/index.html").expect("www/index.html must exist for test");
|
||||||
|
|
||||||
let response = root_landing().await;
|
let response = root_landing().await;
|
||||||
|
|
||||||
assert_eq!(response.status(), StatusCode::OK);
|
assert_eq!(response.status(), StatusCode::OK);
|
||||||
assert!(
|
assert!(response
|
||||||
response.headers().get("content-type").unwrap().to_str().unwrap().contains("text/html")
|
.headers()
|
||||||
);
|
.get("content-type")
|
||||||
|
.unwrap()
|
||||||
|
.to_str()
|
||||||
|
.unwrap()
|
||||||
|
.contains("text/html"));
|
||||||
|
|
||||||
// Convert response body to bytes using axum::body::to_bytes
|
// Convert response body to bytes using axum::body::to_bytes
|
||||||
let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX)
|
let body_bytes = axum::body::to_bytes(response.into_body(), usize::MAX)
|
||||||
@@ -28,9 +33,7 @@ async fn test_root_landing_page() {
|
|||||||
let temp_path = "www/index.html.tmp_test_bak";
|
let temp_path = "www/index.html.tmp_test_bak";
|
||||||
fs::rename(orig_path, temp_path).unwrap();
|
fs::rename(orig_path, temp_path).unwrap();
|
||||||
|
|
||||||
let response_res = tokio::spawn(async move {
|
let response_res = tokio::spawn(async move { root_landing().await }).await;
|
||||||
root_landing().await
|
|
||||||
}).await;
|
|
||||||
|
|
||||||
// Restore index.html immediately in case of panic/error
|
// Restore index.html immediately in case of panic/error
|
||||||
let rename_res = fs::rename(temp_path, orig_path);
|
let rename_res = fs::rename(temp_path, orig_path);
|
||||||
|
|||||||
Reference in new issue
Block a user