refactor: http-axum split into api/html/federation modules, router.rs, templates per page group
This commit is contained in:
@@ -75,7 +75,7 @@ impl domain::ports::PersonQuery for PersonQueryStub {
|
||||
async fn search_endpoint_returns_200_with_empty_results() {
|
||||
let state = crate::extractors::tests::test_app_state_with_search_port(Arc::new(SearchPortStub));
|
||||
let app = Router::new()
|
||||
.route("/api/v1/search", get(crate::handlers::search::get_search))
|
||||
.route("/api/v1/search", get(crate::api::search::get_search))
|
||||
.with_state(state);
|
||||
|
||||
let resp = app
|
||||
@@ -95,7 +95,7 @@ async fn search_endpoint_returns_200_with_empty_results() {
|
||||
async fn search_endpoint_with_no_query_returns_200() {
|
||||
let state = crate::extractors::tests::test_app_state_with_search_port(Arc::new(SearchPortStub));
|
||||
let app = Router::new()
|
||||
.route("/api/v1/search", get(crate::handlers::search::get_search))
|
||||
.route("/api/v1/search", get(crate::api::search::get_search))
|
||||
.with_state(state);
|
||||
|
||||
let resp = app
|
||||
@@ -120,7 +120,7 @@ async fn person_endpoint_returns_404_for_unknown_id() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/people/{id}",
|
||||
get(crate::handlers::search::get_person_handler),
|
||||
get(crate::api::search::get_person_handler),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -145,7 +145,7 @@ async fn person_credits_endpoint_returns_404_for_unknown_id() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/people/{id}/credits",
|
||||
get(crate::handlers::search::get_person_credits_handler),
|
||||
get(crate::api::search::get_person_credits_handler),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -183,7 +183,7 @@ async fn get_watchlist_requires_auth() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/watchlist",
|
||||
get(crate::handlers::watchlist::get_watchlist_handler),
|
||||
get(crate::api::watchlist::get_watchlist_handler),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -266,7 +266,7 @@ async fn pending_count_endpoint_reports_the_use_case_result() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/social/followers/pending/count",
|
||||
get(crate::handlers::social::get_pending_follower_count),
|
||||
get(crate::api::social::get_pending_follower_count),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -295,7 +295,7 @@ async fn get_watchlist_status_requires_auth() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/api/v1/watchlist/{movie_id}",
|
||||
get(crate::handlers::watchlist::get_watchlist_status),
|
||||
get(crate::api::watchlist::get_watchlist_status),
|
||||
)
|
||||
.with_state(state);
|
||||
|
||||
@@ -352,7 +352,7 @@ async fn followers_collection_returns_500_on_federation_error() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/users/{id}/followers",
|
||||
get(crate::handlers::social::get_followers_collection),
|
||||
get(crate::federation::collections::get_followers_collection),
|
||||
)
|
||||
.with_state(state_with_failing_ap_document());
|
||||
|
||||
@@ -376,7 +376,7 @@ async fn following_collection_returns_500_on_federation_error() {
|
||||
let app = Router::new()
|
||||
.route(
|
||||
"/users/{id}/following",
|
||||
get(crate::handlers::social::get_following_collection),
|
||||
get(crate::federation::collections::get_following_collection),
|
||||
)
|
||||
.with_state(state_with_failing_ap_document());
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,119 +0,0 @@
|
||||
use super::*;
|
||||
|
||||
fn make_form(watched_at: &str) -> LogReviewForm {
|
||||
LogReviewForm {
|
||||
external_metadata_id: None,
|
||||
manual_title: None,
|
||||
manual_release_year: None,
|
||||
manual_director: None,
|
||||
rating: 4,
|
||||
comment: None,
|
||||
watched_at: watched_at.to_string(),
|
||||
watch_medium: None,
|
||||
spoilers: false,
|
||||
csrf_token: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn make_request(watched_at: &str) -> LogReviewRequest {
|
||||
LogReviewRequest {
|
||||
external_metadata_id: None,
|
||||
manual_title: None,
|
||||
manual_release_year: None,
|
||||
manual_director: None,
|
||||
rating: 4,
|
||||
comment: None,
|
||||
watched_at: watched_at.to_string(),
|
||||
watch_medium: None,
|
||||
spoilers: false,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn form_accepts_datetime_with_seconds() {
|
||||
let data = LogReviewData::try_from(make_form("2024-03-15T20:30:00")).unwrap();
|
||||
assert_eq!(data.watched_at.format("%H:%M:%S").to_string(), "20:30:00");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn form_accepts_datetime_without_seconds() {
|
||||
let data = LogReviewData::try_from(make_form("2024-03-15T20:30")).unwrap();
|
||||
assert_eq!(data.watched_at.format("%H:%M").to_string(), "20:30");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn form_rejects_invalid_datetime() {
|
||||
assert!(LogReviewData::try_from(make_form("not-a-date")).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn api_accepts_datetime_with_seconds() {
|
||||
let data = LogReviewData::try_from(make_request("2024-03-15T20:30:00")).unwrap();
|
||||
assert_eq!(data.watched_at.format("%H:%M:%S").to_string(), "20:30:00");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn api_accepts_datetime_without_seconds() {
|
||||
let data = LogReviewData::try_from(make_request("2024-03-15T20:30")).unwrap();
|
||||
assert_eq!(data.watched_at.format("%H:%M").to_string(), "20:30");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn api_rejects_invalid_datetime() {
|
||||
assert!(LogReviewData::try_from(make_request("garbage")).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn whitespace_external_id_becomes_none_in_form() {
|
||||
let mut form = make_form("2024-03-15T20:30:00");
|
||||
form.external_metadata_id = Some(" ".to_string());
|
||||
let data = LogReviewData::try_from(form).unwrap();
|
||||
assert!(data.external_metadata_id.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn whitespace_external_id_becomes_none_in_request() {
|
||||
let mut req = make_request("2024-03-15T20:30:00");
|
||||
req.external_metadata_id = Some(" ".to_string());
|
||||
let data = LogReviewData::try_from(req).unwrap();
|
||||
assert!(data.external_metadata_id.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sort_by_asc_string_becomes_ascending() {
|
||||
let params = DiaryQueryParams {
|
||||
sort_by: Some("asc".to_string()),
|
||||
limit: None,
|
||||
offset: None,
|
||||
movie_id: None,
|
||||
user_id: None,
|
||||
};
|
||||
let query = to_diary_query(params);
|
||||
assert!(matches!(
|
||||
query.sort_by,
|
||||
Some(domain::models::ReviewSortBy::Ascending)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sort_by_other_string_becomes_descending() {
|
||||
let params = DiaryQueryParams {
|
||||
sort_by: Some("desc".to_string()),
|
||||
limit: None,
|
||||
offset: None,
|
||||
movie_id: None,
|
||||
user_id: None,
|
||||
};
|
||||
let query = to_diary_query(params);
|
||||
assert!(matches!(
|
||||
query.sort_by,
|
||||
Some(domain::models::ReviewSortBy::Descending)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn form_accepts_date_only() {
|
||||
let data = LogReviewData::try_from(make_form("2024-03-15")).unwrap();
|
||||
assert_eq!(data.watched_at.format("%H:%M:%S").to_string(), "00:00:00");
|
||||
assert_eq!(data.watched_at.format("%Y-%m-%d").to_string(), "2024-03-15");
|
||||
}
|
||||
Reference in New Issue
Block a user