Skip to content

Commit 2c545f8

Browse files
committed
add testcase fror path "/compare.html"
1 parent 8d4da41 commit 2c545f8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

site/src/server.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,5 +836,20 @@ mod tests {
836836
.unwrap();
837837
assert_eq!(response.headers(), expected_response.headers());
838838
assert_eq!(hyper::body::to_bytes(response.into_body()).await.unwrap(), hyper::body::to_bytes(expected_response.into_body()).await.unwrap());
839+
840+
// Test case 2: Path is "/compare.html"
841+
let req = Request::default();
842+
let path = "/compare.html";
843+
let use_compression = false;
844+
let response = handle_fs_path(&req, path, use_compression).await.unwrap();
845+
let expected_body = TEMPLATES.get_template("compare.html").await.unwrap();
846+
let expected_response = http::Response::builder()
847+
.header_typed(ETag::from_str(&format!(r#""{}""#, *VERSION_UUID)).unwrap())
848+
.header(CACHE_CONTROL, "max-age=60, stale-while-revalidate=86400")
849+
.header_typed(ContentType::html())
850+
.body(hyper::Body::from(expected_body))
851+
.unwrap();
852+
assert_eq!(response.headers(), expected_response.headers());
853+
assert_eq!(hyper::body::to_bytes(response.into_body()).await.unwrap(), hyper::body::to_bytes(expected_response.into_body()).await.unwrap());
839854
}
840855
}

0 commit comments

Comments
 (0)