43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
use domain::entities::{Album, AssetTag, Tag, TagSource};
|
|
use domain::errors::DomainError;
|
|
use domain::value_objects::SystemId;
|
|
|
|
// --- Album ---
|
|
|
|
#[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(_))));
|
|
}
|
|
|
|
// --- Tag ---
|
|
|
|
#[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());
|
|
}
|