32 lines
1.0 KiB
Rust
32 lines
1.0 KiB
Rust
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"));
|
|
}
|