Skip to main content

levi_core/entities/
mod.rs

1mod applied;
2mod claim;
3mod comment;
4mod commit_fact;
5mod dependency;
6mod log_entry;
7mod project;
8mod ref_fact;
9mod status_change;
10mod task;
11
12pub use applied::*;
13pub use claim::*;
14pub use comment::*;
15pub use commit_fact::*;
16pub use dependency::*;
17pub use log_entry::*;
18pub use project::*;
19pub use ref_fact::*;
20pub use status_change::*;
21pub use task::*;
22
23#[cfg(test)]
24mod tests {
25    use super::*;
26    use myko::wire::{MEvent, MEventType};
27
28    #[test]
29    fn task_event_cbor_roundtrip() {
30        let t = Task {
31            id: "abc123".into(),
32            project_id: "p".into(),
33            title: "T".into(),
34            body: String::new(),
35            priority: Priority::P1,
36            labels: vec!["x".into()],
37            created_by_dev: "d@e".into(),
38            created_by_machine: "m".into(),
39            created: "2026-07-18T00:00:00Z".into(),
40        };
41        let ev = MEvent::from_item(&t, MEventType::SET, "m");
42        let mut buf = Vec::new();
43        ciborium::into_writer(&ev, &mut buf).unwrap();
44        let back: MEvent = ciborium::from_reader(buf.as_slice()).unwrap();
45        let t2: Task = serde_json::from_value(back.item.clone()).unwrap();
46        assert_eq!(t, t2);
47        assert_eq!(back.item_type, "Task");
48    }
49
50    #[test]
51    fn priority_orders_p0_first() {
52        assert!(Priority::P0.rank() < Priority::P3.rank());
53        assert_eq!(Priority::default(), Priority::P2);
54    }
55}