v0.0.3
RustBox CI / rustbox (push) Canceled after 0s

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-30 00:12:09 +01:00
1 parent a238ff5e23
commit 93762fe9ef
65 files changed
+5420 -2792

No files matched your search

+15 -1
View File
@@ -33,6 +33,8 @@ pub enum AppError {
Forbidden(String),
/// Service unavailable (503).
ServiceUnavailable(String),
/// Request payload is larger than the configured mail limit (413).
PayloadTooLarge(String),
}
impl AppError {
@@ -45,6 +47,7 @@ impl AppError {
AppError::BadRequest(_) => StatusCode::BAD_REQUEST,
AppError::Forbidden(_) => StatusCode::FORBIDDEN,
AppError::ServiceUnavailable(_) => StatusCode::SERVICE_UNAVAILABLE,
AppError::PayloadTooLarge(_) => StatusCode::PAYLOAD_TOO_LARGE,
}
}
@@ -57,6 +60,7 @@ impl AppError {
AppError::BadRequest(_) => "BAD_REQUEST",
AppError::Forbidden(_) => "FORBIDDEN",
AppError::ServiceUnavailable(_) => "SERVICE_UNAVAILABLE",
AppError::PayloadTooLarge(_) => "PAYLOAD_TOO_LARGE",
}
}
@@ -68,7 +72,8 @@ impl AppError {
| AppError::Unauthorized(msg)
| AppError::BadRequest(msg)
| AppError::Forbidden(msg)
| AppError::ServiceUnavailable(msg) => msg,
| AppError::ServiceUnavailable(msg)
| AppError::PayloadTooLarge(msg) => msg,
}
}
}
@@ -162,6 +167,15 @@ mod tests {
assert_eq!(json["error"]["status"], 403);
}
#[tokio::test]
async fn payload_too_large_returns_413() {
let (status, json) =
error_to_json(AppError::PayloadTooLarge("message too large".into())).await;
assert_eq!(status, StatusCode::PAYLOAD_TOO_LARGE);
assert_eq!(json["error"]["code"], "PAYLOAD_TOO_LARGE");
assert_eq!(json["error"]["status"], 413);
}
#[tokio::test]
async fn service_unavailable_returns_503() {
let (status, json) = error_to_json(AppError::ServiceUnavailable("IMAP down".into())).await;