2025-03-03 16:05:39 -08:00
|
|
|
use crate::common::api_common::ApiProject;
|
2024-01-06 11:08:03 -08:00
|
|
|
|
2024-01-05 08:20:56 -08:00
|
|
|
use actix_http::StatusCode;
|
2023-12-01 19:15:00 -08:00
|
|
|
use actix_web::test;
|
|
|
|
|
use bytes::Bytes;
|
|
|
|
|
|
2025-11-08 12:26:24 -08:00
|
|
|
use crate::assert_status;
|
2025-03-03 16:05:39 -08:00
|
|
|
use crate::common::database::USER_USER_PAT;
|
|
|
|
|
use crate::common::{
|
2023-12-01 19:15:00 -08:00
|
|
|
api_v2::ApiV2,
|
2025-05-09 07:27:55 -05:00
|
|
|
environment::{TestEnvironment, with_test_environment},
|
2023-12-01 19:15:00 -08:00
|
|
|
};
|
2025-11-08 12:26:24 -08:00
|
|
|
|
2023-12-01 19:15:00 -08:00
|
|
|
#[actix_rt::test]
|
|
|
|
|
pub async fn error_404_empty() {
|
2024-10-18 16:07:35 -07:00
|
|
|
with_test_environment(
|
|
|
|
|
None,
|
|
|
|
|
|test_env: TestEnvironment<ApiV2>| async move {
|
|
|
|
|
// V2 errors should have 404 as blank body, for missing resources
|
|
|
|
|
let api = &test_env.api;
|
|
|
|
|
let resp = api.get_project("does-not-exist", USER_USER_PAT).await;
|
|
|
|
|
assert_status!(&resp, StatusCode::NOT_FOUND);
|
|
|
|
|
let body = test::read_body(resp).await;
|
|
|
|
|
let empty_bytes = Bytes::from_static(b"");
|
|
|
|
|
assert_eq!(body, empty_bytes);
|
|
|
|
|
},
|
|
|
|
|
)
|
2023-12-01 19:15:00 -08:00
|
|
|
.await;
|
|
|
|
|
}
|