forked from janek/mostr
1
0
Fork 0

test(tasks): small rearrangements

This commit is contained in:
xeruf 2024-08-14 16:00:03 +03:00
parent 1e0cc319b8
commit b544616801
1 changed files with 7 additions and 6 deletions

View File

@ -1057,20 +1057,20 @@ mod tasks_test {
tasks.make_task_and_enter("proc: tags", State::Procedure); tasks.make_task_and_enter("proc: tags", State::Procedure);
let side = tasks.submit(build_task("side", vec![tasks.make_event_tag(&tasks.get_current_task().unwrap().event, MARKER_DEPENDS)])); let side = tasks.submit(build_task("side", vec![tasks.make_event_tag(&tasks.get_current_task().unwrap().event, MARKER_DEPENDS)]));
assert_eq!(tasks.get_current_task().unwrap().children, HashSet::<EventId>::new()); assert_eq!(tasks.get_current_task().unwrap().children, HashSet::<EventId>::new());
let subid = tasks.make_task("sub"); let sub_id = tasks.make_task("sub");
assert_eq!(tasks.get_current_task().unwrap().children, HashSet::from([subid])); assert_eq!(tasks.get_current_task().unwrap().children, HashSet::from([sub_id]));
let sub = tasks.get_by_id(&subid).unwrap(); assert_eq!(tasks.len(), 3);
let sub = tasks.get_by_id(&sub_id).unwrap();
assert_eq!(sub.get_dependendees(), Vec::<&EventId>::new()); assert_eq!(sub.get_dependendees(), Vec::<&EventId>::new());
} }
#[test] #[test]
fn test_tracking() { fn test_tracking() {
let mut tasks = stub_tasks(); let mut tasks = stub_tasks();
let zero = EventId::all_zeros();
//let task = tasks.make_task("task");
tasks.track_at(Timestamp::from(0)); tasks.track_at(Timestamp::from(0));
assert_eq!(tasks.history.len(), 1); assert_eq!(tasks.history.len(), 1);
let zero = EventId::all_zeros();
tasks.move_to(Some(zero)); tasks.move_to(Some(zero));
let now: Timestamp = Timestamp::now() - 2u64; let now: Timestamp = Timestamp::now() - 2u64;
@ -1090,10 +1090,11 @@ mod tasks_test {
fn test_timestamps() { fn test_timestamps() {
let mut tasks = stub_tasks(); let mut tasks = stub_tasks();
let zero = EventId::all_zeros(); let zero = EventId::all_zeros();
tasks.move_to(Some(zero)); tasks.move_to(Some(zero));
tasks.track_at(Timestamp::from(Timestamp::now().as_u64() + 100)); tasks.track_at(Timestamp::from(Timestamp::now().as_u64() + 100));
assert_eq!(timestamps(tasks.history.values().nth(0).unwrap().into_iter(), &vec![&zero]).collect_vec().len(), 2) assert_eq!(timestamps(tasks.history.values().nth(0).unwrap().into_iter(), &vec![&zero]).collect_vec().len(), 2)
// TODO Does not show both future and current tracking properly, need to split by now // TODO Does not show both future and current tracking properly, need to split by current time
} }