Refactor test stubs and consolidate panic implementations

- Removed redundant panic repository implementations in `event_handlers.rs` and `extractors.rs`.
- Introduced a single `Panic` struct to serve as a stub for various repository and service traits.
- Simplified test state creation by using a factory function `make_test_state` to reduce code duplication.
- Updated tests to utilize the new panic implementation and streamlined router setup for better readability.
This commit is contained in:
2026-05-09 20:07:44 +02:00
parent 89e78a0d1f
commit 1eaa3ca8a6
3 changed files with 143 additions and 479 deletions

View File

@@ -336,14 +336,6 @@ mod tests {
assert!(data.external_metadata_id.is_none());
}
#[test]
fn into_command_sets_user_id() {
let data = LogReviewData::try_from(make_form("2024-03-15T20:30:00")).unwrap();
let user_id = Uuid::new_v4();
let cmd = data.into_command(user_id);
assert_eq!(cmd.user_id, user_id);
}
#[test]
fn sort_by_asc_string_becomes_ascending() {
let params = DiaryQueryParams {
@@ -368,38 +360,6 @@ mod tests {
assert!(matches!(query.sort_by, Some(domain::models::SortDirection::Descending)));
}
#[test]
fn diary_response_serializes_correctly() {
let resp = DiaryResponse {
items: vec![],
total_count: 0,
limit: 20,
offset: 0,
};
let json = serde_json::to_string(&resp).unwrap();
assert!(json.contains("\"total_count\":0"));
assert!(json.contains("\"items\":[]"));
}
#[test]
fn diary_query_params_fields_are_optional() {
let params = DiaryQueryParams {
limit: None,
offset: None,
sort_by: None,
movie_id: None,
};
assert!(params.limit.is_none());
assert!(params.sort_by.is_none());
}
#[test]
fn login_request_deserializes() {
let json = r#"{"email":"a@b.com","password":"secret"}"#;
let req: LoginRequest = serde_json::from_str(json).unwrap();
assert_eq!(req.email, "a@b.com");
}
#[test]
fn form_accepts_date_only() {
let data = LogReviewData::try_from(make_form("2024-03-15")).unwrap();