httpd: Fix error status code on project not found

It was 500, should be 404.
This commit is contained in:
cloudhead 2023-08-09 12:01:14 +02:00
parent 1b9906db09
commit 5654f08841
No known key found for this signature in database
2 changed files with 10 additions and 0 deletions

View File

@ -97,6 +97,7 @@ impl IntoResponse for Error {
StatusCode::INTERNAL_SERVER_ERROR,
Some(e.message().to_owned()),
),
Error::Storage(err) if err.is_not_found() => (StatusCode::NOT_FOUND, None),
Error::BadRequest(msg) => (StatusCode::BAD_REQUEST, Some(msg)),
other => {
tracing::error!("Error: {message}");

View File

@ -836,6 +836,15 @@ mod routes {
);
}
#[tokio::test]
async fn test_projects_not_found() {
let tmp = tempfile::tempdir().unwrap();
let app = super::router(seed(tmp.path()));
let response = get(&app, "/projects/rad:z2u2CP3ZJzB7ZqE8jHrau19yjcfCQ").await;
assert_eq!(response.status(), StatusCode::NOT_FOUND);
}
#[tokio::test]
async fn test_projects_commits_root() {
let tmp = tempfile::tempdir().unwrap();