collapse 20 pass-through use cases; handlers call ports directly
delete get/list/list_by_owner channels, get_settings/activity_log admin, get_item/get_sync_status/list_collections/list_seasons/list_shows/list_genres library, get/list/delete providers, get/list/patch_label config_snapshots, get_active/list_history/delete_after schedule — all single-delegation. remove ChannelQueryDeps, LibraryQueryDeps, deleted query/command structs. add direct port fields to AppState. update MCP crate accordingly.
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
use domain::models::ActivityEvent;
|
||||
use domain::DomainResult;
|
||||
|
||||
use super::deps::AdminDeps;
|
||||
use super::queries::GetActivityLogQuery;
|
||||
|
||||
pub async fn execute(
|
||||
deps: &AdminDeps,
|
||||
query: GetActivityLogQuery,
|
||||
) -> DomainResult<Vec<ActivityEvent>> {
|
||||
deps.activity_query.recent(query.limit).await
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
use domain::DomainResult;
|
||||
|
||||
use super::deps::AdminDeps;
|
||||
use super::queries::GetSettingsQuery;
|
||||
|
||||
pub async fn execute(
|
||||
deps: &AdminDeps,
|
||||
_query: GetSettingsQuery,
|
||||
) -> DomainResult<Vec<(String, String)>> {
|
||||
deps.settings_repo.get_all().await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/get_settings.rs"]
|
||||
mod tests;
|
||||
@@ -1,10 +1,6 @@
|
||||
pub mod activity_log;
|
||||
pub mod commands;
|
||||
pub mod deps;
|
||||
pub mod get_settings;
|
||||
pub mod queries;
|
||||
pub mod update_settings;
|
||||
|
||||
pub use commands::UpdateSettingsCommand;
|
||||
pub use deps::AdminDeps;
|
||||
pub use queries::{GetActivityLogQuery, GetSettingsQuery};
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
pub struct GetSettingsQuery;
|
||||
|
||||
pub struct GetActivityLogQuery {
|
||||
pub limit: u32,
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::testing::{InMemoryActivityLog, InMemoryAppSettings};
|
||||
|
||||
use crate::admin::commands::UpdateSettingsCommand;
|
||||
use crate::admin::deps::AdminDeps;
|
||||
use crate::admin::queries::GetSettingsQuery;
|
||||
use crate::admin::{get_settings, update_settings};
|
||||
|
||||
fn make_deps() -> AdminDeps {
|
||||
AdminDeps {
|
||||
settings_repo: Arc::new(InMemoryAppSettings::new()),
|
||||
activity_query: Arc::new(InMemoryActivityLog::new()),
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn get_empty_settings() {
|
||||
let deps = make_deps();
|
||||
let settings = get_settings::execute(&deps, GetSettingsQuery).await.unwrap();
|
||||
assert!(settings.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn get_returns_stored_settings() {
|
||||
let deps = make_deps();
|
||||
|
||||
update_settings::execute(
|
||||
&deps,
|
||||
UpdateSettingsCommand {
|
||||
settings: vec![
|
||||
("a".into(), "1".into()),
|
||||
("b".into(), "2".into()),
|
||||
],
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let settings = get_settings::execute(&deps, GetSettingsQuery).await.unwrap();
|
||||
assert_eq!(settings.len(), 2);
|
||||
|
||||
let keys: Vec<&str> = settings.iter().map(|(k, _)| k.as_str()).collect();
|
||||
assert!(keys.contains(&"a"));
|
||||
assert!(keys.contains(&"b"));
|
||||
}
|
||||
Reference in New Issue
Block a user