domain: add Organization entities and ports (Album, Tag, Collection, FilterCriteria)
This commit is contained in:
27
crates/domain/tests/entities/album.rs
Normal file
27
crates/domain/tests/entities/album.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use domain::entities::Album;
|
||||
use domain::errors::DomainError;
|
||||
use domain::value_objects::SystemId;
|
||||
|
||||
#[test]
|
||||
fn add_and_remove_asset() {
|
||||
let mut album = Album::new("Vacation", SystemId::new());
|
||||
let asset = SystemId::new();
|
||||
let user = SystemId::new();
|
||||
|
||||
album.add_asset(asset.clone(), user.clone()).unwrap();
|
||||
assert_eq!(album.asset_count(), 1);
|
||||
|
||||
album.remove_asset(&asset).unwrap();
|
||||
assert_eq!(album.asset_count(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cannot_add_duplicate() {
|
||||
let mut album = Album::new("Vacation", SystemId::new());
|
||||
let asset = SystemId::new();
|
||||
let user = SystemId::new();
|
||||
|
||||
album.add_asset(asset.clone(), user.clone()).unwrap();
|
||||
let result = album.add_asset(asset, user);
|
||||
assert!(matches!(result, Err(DomainError::Conflict(_))));
|
||||
}
|
||||
@@ -11,3 +11,5 @@ mod asset_metadata;
|
||||
mod asset_stack;
|
||||
mod derivative_asset;
|
||||
mod duplicate;
|
||||
mod album;
|
||||
mod tag;
|
||||
|
||||
13
crates/domain/tests/entities/tag.rs
Normal file
13
crates/domain/tests/entities/tag.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use domain::entities::{AssetTag, Tag, TagSource};
|
||||
use domain::value_objects::SystemId;
|
||||
|
||||
#[test]
|
||||
fn manual_tag_has_full_confidence() {
|
||||
let tag = Tag::new_manual("sunset");
|
||||
assert_eq!(tag.name, "sunset");
|
||||
assert_eq!(tag.tag_source, TagSource::UserManual);
|
||||
|
||||
let asset_tag = AssetTag::new_manual(SystemId::new(), tag.tag_id.clone(), SystemId::new());
|
||||
assert_eq!(asset_tag.confidence, 1.0);
|
||||
assert!(asset_tag.tagged_by_user_id.is_some());
|
||||
}
|
||||
Reference in New Issue
Block a user