Skip to content

Commit 2c3a550

Browse files
committed
add testcase fror path "/compare.html"
1 parent 2ed8f42 commit 2c3a550

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

site/src/server.rs

+15
Original file line numberDiff line numberDiff line change
@@ -828,5 +828,20 @@ mod tests {
828828
.unwrap();
829829
assert_eq!(response.headers(), expected_response.headers());
830830
assert_eq!(hyper::body::to_bytes(response.into_body()).await.unwrap(), hyper::body::to_bytes(expected_response.into_body()).await.unwrap());
831+
832+
// Test case 2: Path is "/compare.html"
833+
let req = Request::default();
834+
let path = "/compare.html";
835+
let use_compression = false;
836+
let response = handle_fs_path(&req, path, use_compression).await.unwrap();
837+
let expected_body = TEMPLATES.get_template("compare.html").await.unwrap();
838+
let expected_response = http::Response::builder()
839+
.header_typed(ETag::from_str(&format!(r#""{}""#, *VERSION_UUID)).unwrap())
840+
.header(CACHE_CONTROL, "max-age=60, stale-while-revalidate=86400")
841+
.header_typed(ContentType::html())
842+
.body(hyper::Body::from(expected_body))
843+
.unwrap();
844+
assert_eq!(response.headers(), expected_response.headers());
845+
assert_eq!(hyper::body::to_bytes(response.into_body()).await.unwrap(), hyper::body::to_bytes(expected_response.into_body()).await.unwrap());
831846
}
832847
}

0 commit comments

Comments
 (0)