domain: add Sidecar Sync entities and ports (SidecarRecord, SidecarConfig, SidecarWriterPort)
This commit is contained in:
@@ -15,3 +15,4 @@ mod album;
|
||||
mod tag;
|
||||
mod share_scope;
|
||||
mod share_link;
|
||||
mod sidecar_record;
|
||||
|
||||
31
crates/domain/tests/entities/sidecar_record.rs
Normal file
31
crates/domain/tests/entities/sidecar_record.rs
Normal 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"));
|
||||
}
|
||||
Reference in New Issue
Block a user