app: add storage commands/queries + missing in-memory test repos

This commit is contained in:
2026-05-31 05:11:02 +02:00
parent fa36bb8c0e
commit 4549d746c3
16 changed files with 1040 additions and 5 deletions

View File

@@ -0,0 +1,30 @@
use std::sync::Arc;
use application::testing::InMemoryStorageVolumeRepository;
use application::storage::{RegisterVolumeCommand, RegisterVolumeHandler};
use domain::errors::DomainError;
#[tokio::test]
async fn creates_volume() {
let repo = Arc::new(InMemoryStorageVolumeRepository::new());
let handler = RegisterVolumeHandler::new(repo);
let vol = handler.execute(RegisterVolumeCommand {
volume_name: "primary".into(),
uri_prefix: "file:///data".into(),
is_writable: true,
}).await.unwrap();
assert_eq!(vol.volume_name, "primary");
assert_eq!(vol.uri_prefix, "file:///data");
assert!(vol.is_writable);
}
#[tokio::test]
async fn rejects_empty_name() {
let repo = Arc::new(InMemoryStorageVolumeRepository::new());
let handler = RegisterVolumeHandler::new(repo);
let result = handler.execute(RegisterVolumeCommand {
volume_name: "".into(),
uri_prefix: "file:///data".into(),
is_writable: true,
}).await;
assert!(matches!(result, Err(DomainError::Validation(_))));
}