domain: add Sidecar Sync entities and ports (SidecarRecord, SidecarConfig, SidecarWriterPort)

This commit is contained in:
2026-05-31 03:34:04 +02:00
parent ba53e0fa70
commit ee79be0351
8 changed files with 150 additions and 0 deletions

View File

@@ -15,3 +15,4 @@ mod album;
mod tag;
mod share_scope;
mod share_link;
mod sidecar_record;

View File

@@ -0,0 +1,31 @@
use domain::entities::{SidecarRecord, SyncStatus};
use domain::value_objects::{Checksum, SystemId};
#[test]
fn new_is_pending_write() {
let record = SidecarRecord::new(SystemId::new(), "/path/to/sidecar.xmp");
assert_eq!(record.sync_status, SyncStatus::PendingWrite);
assert!(record.last_synced_at.is_none());
assert!(record.last_known_file_hash.is_none());
}
#[test]
fn sync_lifecycle() {
let mut record = SidecarRecord::new(SystemId::new(), "/path/to/sidecar.xmp");
let hash = Checksum::new("a".repeat(64)).unwrap();
record.mark_synced(hash);
assert_eq!(record.sync_status, SyncStatus::InSync);
assert!(record.last_synced_at.is_some());
assert!(record.last_known_file_hash.is_some());
record.mark_pending_read();
assert_eq!(record.sync_status, SyncStatus::PendingRead);
record.mark_conflict();
assert_eq!(record.sync_status, SyncStatus::Conflict);
record.mark_error("disk full");
assert_eq!(record.sync_status, SyncStatus::Error);
assert_eq!(record.error_message.as_deref(), Some("disk full"));
}