test: move http-axum tests to tests/
Drop bootstrap dev-dep. Extractor + api handler + app-context tests (need full AppState via build_deps) -> bootstrap/tests/http_handlers/. forms tests -> http-axum/tests/log_review_form_test.rs. Federation collection tests now go through public federation::html_routes(). Kept inline (private fns): api/social social_actor_to_dto (4), federation/blocklist_api social_actor_to_blocked_dto (1), html/social social_actor_to_template (1), router slow_down/api_governor (2).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::extractors::tests::{AcceptingAuth, test_app_state, test_app_state_with_follow_graph};
|
||||
use crate::support::{AcceptingAuth, test_app_state, test_app_state_with_follow_graph};
|
||||
use axum::{
|
||||
Router,
|
||||
body::Body,
|
||||
@@ -73,9 +73,9 @@ impl domain::ports::PersonQuery for PersonQueryStub {
|
||||
|
||||
#[tokio::test]
|
||||
async fn search_endpoint_returns_200_with_empty_results() {
|
||||
let state = crate::extractors::tests::test_app_state_with_search_port(Arc::new(SearchPortStub));
|
||||
let state = crate::support::test_app_state_with_search_port(Arc::new(SearchPortStub));
|
||||
let app = Router::new()
|
||||
.route("/api/v1/search", get(crate::api::search::get_search))
|
||||
.route("/api/v1/search", get(http_axum::api::search::get_search))
|
||||
.with_state(state);
|
||||
|
||||
let resp = app
|
||||
@@ -93,9 +93,9 @@ async fn search_endpoint_returns_200_with_empty_results() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn search_endpoint_with_no_query_returns_200() {
|
||||
let state = crate::extractors::tests::test_app_state_with_search_port(Arc::new(SearchPortStub));
|
||||
let state = crate::support::test_app_state_with_search_port(Arc::new(SearchPortStub));
|
||||
let app = Router::new()
|
||||
.route("/api/v1/search", get(crate::api::search::get_search))
|
||||
.route("/api/v1/search", get(http_axum::api::search::get_search))
|
||||
.with_state(state);
|
||||
|
||||
let resp = app
|
||||
@@ -115,12 +115,11 @@ async fn search_endpoint_with_no_query_returns_200() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn person_endpoint_returns_404_for_unknown_id() {
|
||||
let state =
|
||||
crate::extractors::tests::test_app_state_with_person_query(Arc::new(PersonQueryStub));
|
||||
let state = crate::support::test_app_state_with_person_query(Arc::new(PersonQueryStub));
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/people/{id}",
|
||||
get(crate::api::search::get_person_handler),
|
||||
get(http_axum::api::search::get_person_handler),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -140,12 +139,11 @@ async fn person_endpoint_returns_404_for_unknown_id() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn person_credits_endpoint_returns_404_for_unknown_id() {
|
||||
let state =
|
||||
crate::extractors::tests::test_app_state_with_person_query(Arc::new(PersonQueryStub));
|
||||
let state = crate::support::test_app_state_with_person_query(Arc::new(PersonQueryStub));
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/people/{id}/credits",
|
||||
get(crate::api::search::get_person_credits_handler),
|
||||
get(http_axum::api::search::get_person_credits_handler),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -166,7 +164,7 @@ async fn person_credits_endpoint_returns_404_for_unknown_id() {
|
||||
#[test]
|
||||
fn injected_stub_reaches_prebuilt_deps() {
|
||||
let stub: Arc<dyn domain::ports::PersonQuery> = Arc::new(PersonQueryStub);
|
||||
let state = crate::extractors::tests::test_app_state_with_person_query(Arc::clone(&stub));
|
||||
let state = crate::support::test_app_state_with_person_query(Arc::clone(&stub));
|
||||
|
||||
assert!(
|
||||
Arc::ptr_eq(&state.app_ctx.deps.person.get_person.person_query, &stub),
|
||||
@@ -183,7 +181,7 @@ async fn get_watchlist_requires_auth() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/watchlist",
|
||||
get(crate::api::watchlist::get_watchlist_handler),
|
||||
get(http_axum::api::watchlist::get_watchlist_handler),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -266,7 +264,7 @@ async fn pending_count_endpoint_reports_the_use_case_result() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/social/followers/pending/count",
|
||||
get(crate::api::social::get_pending_follower_count),
|
||||
get(http_axum::api::social::get_pending_follower_count),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -295,7 +293,7 @@ async fn get_watchlist_status_requires_auth() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/watchlist/{movie_id}",
|
||||
get(crate::api::watchlist::get_watchlist_status),
|
||||
get(http_axum::api::watchlist::get_watchlist_status),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -340,7 +338,7 @@ impl domain::ports::ApDocumentPort for FailingApDocument {
|
||||
}
|
||||
|
||||
#[cfg(feature = "federation")]
|
||||
fn state_with_failing_ap_document() -> crate::state::AppState {
|
||||
fn state_with_failing_ap_document() -> http_axum::state::AppState {
|
||||
let mut state = test_app_state();
|
||||
state.app_ctx.ap_document = Arc::new(FailingApDocument);
|
||||
state
|
||||
@@ -349,12 +347,7 @@ fn state_with_failing_ap_document() -> crate::state::AppState {
|
||||
#[cfg(feature = "federation")]
|
||||
#[tokio::test]
|
||||
async fn followers_collection_returns_500_on_federation_error() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/users/{id}/followers",
|
||||
get(crate::federation::collections::get_followers_collection),
|
||||
)
|
||||
.with_state(state_with_failing_ap_document());
|
||||
let app = http_axum::federation::html_routes().with_state(state_with_failing_ap_document());
|
||||
|
||||
let resp = app
|
||||
.oneshot(
|
||||
@@ -373,12 +366,7 @@ async fn followers_collection_returns_500_on_federation_error() {
|
||||
#[cfg(feature = "federation")]
|
||||
#[tokio::test]
|
||||
async fn following_collection_returns_500_on_federation_error() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/users/{id}/following",
|
||||
get(crate::federation::collections::get_following_collection),
|
||||
)
|
||||
.with_state(state_with_failing_ap_document());
|
||||
let app = http_axum::federation::html_routes().with_state(state_with_failing_ap_document());
|
||||
|
||||
let resp = app
|
||||
.oneshot(
|
||||
@@ -405,12 +393,11 @@ async fn refusal_body(resp: axum::response::Response) -> serde_json::Value {
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_missing_resource_is_refused_with_not_found_code() {
|
||||
let state =
|
||||
crate::extractors::tests::test_app_state_with_person_query(Arc::new(PersonQueryStub));
|
||||
let state = crate::support::test_app_state_with_person_query(Arc::new(PersonQueryStub));
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/people/{id}",
|
||||
get(crate::api::search::get_person_handler),
|
||||
get(http_axum::api::search::get_person_handler),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -435,7 +422,7 @@ async fn a_missing_credential_is_refused_with_unauthorized_code() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/watchlist",
|
||||
get(crate::api::watchlist::get_watchlist_handler),
|
||||
get(http_axum::api::watchlist::get_watchlist_handler),
|
||||
)
|
||||
.with_state(test_app_state());
|
||||
|
||||
@@ -455,12 +442,11 @@ async fn a_missing_credential_is_refused_with_unauthorized_code() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_malformed_path_parameter_is_refused_with_invalid_input_code() {
|
||||
let state =
|
||||
crate::extractors::tests::test_app_state_with_person_query(Arc::new(PersonQueryStub));
|
||||
let state = crate::support::test_app_state_with_person_query(Arc::new(PersonQueryStub));
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/people/{id}",
|
||||
get(crate::api::search::get_person_handler),
|
||||
get(http_axum::api::search::get_person_handler),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -483,7 +469,7 @@ async fn a_malformed_json_body_is_refused_with_invalid_input_code() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/auth/login",
|
||||
axum::routing::post(crate::api::auth::login),
|
||||
axum::routing::post(http_axum::api::auth::login),
|
||||
)
|
||||
.with_state(test_app_state());
|
||||
|
||||
@@ -510,7 +496,7 @@ async fn a_json_body_of_the_wrong_shape_is_refused_as_unprocessable() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/auth/login",
|
||||
axum::routing::post(crate::api::auth::login),
|
||||
axum::routing::post(http_axum::api::auth::login),
|
||||
)
|
||||
.with_state(test_app_state());
|
||||
|
||||
@@ -535,7 +521,7 @@ async fn a_non_multipart_upload_is_refused_with_invalid_input_code() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/webhooks/plex",
|
||||
axum::routing::post(crate::api::webhook::post_plex_webhook),
|
||||
axum::routing::post(http_axum::api::webhook::post_plex_webhook),
|
||||
)
|
||||
.with_state(test_app_state());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user