style: cargo fmt --all
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
use std::sync::Arc;
|
||||
use application::testing::{InMemoryStorageVolumeRepository, InMemoryLibraryPathRepository};
|
||||
use application::storage::{RegisterVolumeCommand, RegisterVolumeHandler, RegisterLibraryPathCommand, RegisterLibraryPathHandler};
|
||||
use application::storage::{
|
||||
RegisterLibraryPathCommand, RegisterLibraryPathHandler, RegisterVolumeCommand,
|
||||
RegisterVolumeHandler,
|
||||
};
|
||||
use application::testing::{InMemoryLibraryPathRepository, InMemoryStorageVolumeRepository};
|
||||
use domain::errors::DomainError;
|
||||
use domain::value_objects::SystemId;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[tokio::test]
|
||||
async fn creates_path() {
|
||||
@@ -10,20 +13,26 @@ async fn creates_path() {
|
||||
let path_repo = Arc::new(InMemoryLibraryPathRepository::new());
|
||||
|
||||
let vol_handler = RegisterVolumeHandler::new(vol_repo.clone());
|
||||
let vol = vol_handler.execute(RegisterVolumeCommand {
|
||||
volume_name: "main".into(),
|
||||
uri_prefix: "file:///data".into(),
|
||||
is_writable: true,
|
||||
}).await.unwrap();
|
||||
let vol = vol_handler
|
||||
.execute(RegisterVolumeCommand {
|
||||
volume_name: "main".into(),
|
||||
uri_prefix: "file:///data".into(),
|
||||
is_writable: true,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let handler = RegisterLibraryPathHandler::new(vol_repo, path_repo);
|
||||
let owner = SystemId::new();
|
||||
let path = handler.execute(RegisterLibraryPathCommand {
|
||||
volume_id: vol.volume_id,
|
||||
relative_path: "photos/inbox".into(),
|
||||
owner_id: owner,
|
||||
is_ingest_destination: true,
|
||||
}).await.unwrap();
|
||||
let path = handler
|
||||
.execute(RegisterLibraryPathCommand {
|
||||
volume_id: vol.volume_id,
|
||||
relative_path: "photos/inbox".into(),
|
||||
owner_id: owner,
|
||||
is_ingest_destination: true,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(path.volume_id, vol.volume_id);
|
||||
assert_eq!(path.relative_path, "photos/inbox");
|
||||
@@ -37,11 +46,13 @@ async fn rejects_nonexistent_volume() {
|
||||
let path_repo = Arc::new(InMemoryLibraryPathRepository::new());
|
||||
let handler = RegisterLibraryPathHandler::new(vol_repo, path_repo);
|
||||
|
||||
let result = handler.execute(RegisterLibraryPathCommand {
|
||||
volume_id: SystemId::new(),
|
||||
relative_path: "photos/inbox".into(),
|
||||
owner_id: SystemId::new(),
|
||||
is_ingest_destination: true,
|
||||
}).await;
|
||||
let result = handler
|
||||
.execute(RegisterLibraryPathCommand {
|
||||
volume_id: SystemId::new(),
|
||||
relative_path: "photos/inbox".into(),
|
||||
owner_id: SystemId::new(),
|
||||
is_ingest_destination: true,
|
||||
})
|
||||
.await;
|
||||
assert!(matches!(result, Err(DomainError::NotFound(_))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user