Memoise the flat route-D render endpoints

This commit is contained in:
gloamxun committed 2026-10-24 23:45:28 +08:00
1 parent 476be05163
commit cca108dc15
5 files changed
+115 -6

No files matched your search

+25
View File
@@ -1005,6 +1005,31 @@ Second paragraph",
assert!(value["pages"][0]["hash"].as_str().unwrap().len() == 16);
}
#[test]
fn caches_flat_route_d_previews_and_pdfs() {
let server = TestServer::start("route-d-flat-cache");
let source = b"Hello cached render";
let first = server.request("POST", "/api/route-d/preview", source, "text/plain");
assert_eq!(first.status, 200, "{}", first.text());
assert_eq!(first.header("x-texrra-cache"), Some("miss"));
let second = server.request("POST", "/api/route-d/preview", source, "text/plain");
assert_eq!(second.status, 200);
assert_eq!(second.header("x-texrra-cache"), Some("hit"));
assert_eq!(first.body, second.body);
let other = server.request("POST", "/api/route-d/preview", b"Other text", "text/plain");
assert_eq!(other.header("x-texrra-cache"), Some("miss"));
let first_pdf = server.request("POST", "/api/route-d/pdf", source, "text/plain");
assert_eq!(first_pdf.status, 200);
assert_eq!(first_pdf.header("x-texrra-cache"), Some("miss"));
let second_pdf = server.request("POST", "/api/route-d/pdf", source, "text/plain");
assert_eq!(second_pdf.status, 200);
assert_eq!(second_pdf.header("x-texrra-cache"), Some("hit"));
assert_eq!(first_pdf.body, second_pdf.body);
let other_pdf = server.request("POST", "/api/route-d/pdf", b"Other text", "text/plain");
assert_eq!(other_pdf.header("x-texrra-cache"), Some("miss"));
}
#[test]
fn exports_route_d_pdf() {
let server = TestServer::start("route-d-pdf");