app: add storage commands/queries + missing in-memory test repos
This commit is contained in:
30
crates/application/tests/storage/commands/register_volume.rs
Normal file
30
crates/application/tests/storage/commands/register_volume.rs
Normal 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(_))));
|
||||
}
|
||||
Reference in New Issue
Block a user