refactor: restructure domain crate by bounded context
This commit is contained in:
42
crates/domain/tests/organization/entities.rs
Normal file
42
crates/domain/tests/organization/entities.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
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());
|
||||
}
|
||||
1
crates/domain/tests/organization/mod.rs
Normal file
1
crates/domain/tests/organization/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
mod entities;
|
||||
Reference in New Issue
Block a user