Answer flat route-D errors with JSON messages
This commit is contained in:
1 parent
9cd8721846
commit
e3e230042a
5 files changed
+28
-6
No files matched your search
@@ -1129,6 +1129,28 @@ fn caches_flat_route_d_previews_and_pdfs() {
|
||||
assert_eq!(other_pdf.header("x-texrra-cache"), Some("miss"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flat_route_d_errors_are_json() {
|
||||
let server = TestServer::start("route-d-flat-errors");
|
||||
for path in ["/api/route-d/preview", "/api/route-d/pdf"] {
|
||||
let first = server.request("POST", path, b"", "text/plain");
|
||||
assert_eq!(first.status, 422, "{}", first.text());
|
||||
assert_eq!(
|
||||
first.header("content-type"),
|
||||
Some("application/json; charset=utf-8")
|
||||
);
|
||||
assert!(
|
||||
first.text().starts_with("{\"error\":\""),
|
||||
"{}",
|
||||
first.text()
|
||||
);
|
||||
let second = server.request("POST", path, b"", "text/plain");
|
||||
assert_eq!(second.status, 422);
|
||||
assert_eq!(second.body, first.body);
|
||||
assert_eq!(second.header("x-texrra-cache"), None);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exports_route_d_pdf() {
|
||||
let server = TestServer::start("route-d-pdf");
|
||||
|
||||
Reference in new issue
Block a user