MCPcopy Create free account
hub / github.com/block/buzz / test_has_flushable_work

Function test_has_flushable_work

crates/buzz-acp/src/queue.rs:2658–2693  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2656
2657 #[test]
2658 fn test_has_flushable_work() {
2659 let mut q = EventQueue::new(DedupMode::Queue);
2660 let ch = Uuid::new_v4();
2661
2662 // Empty queue — no flushable work.
2663 assert!(!q.has_flushable_work());
2664
2665 q.push(make_queued(ch, "msg"));
2666 assert!(q.has_flushable_work());
2667
2668 // Flush — now in-flight, no flushable work.
2669 let _batch = q.flush_next().expect("flush");
2670 assert!(!q.has_flushable_work());
2671
2672 // Complete — no pending events, no flushable work.
2673 q.mark_complete(ch);
2674 assert!(!q.has_flushable_work());
2675
2676 // Requeue with retry_after — throttled, no flushable work.
2677 q.push(make_queued(ch, "msg2"));
2678 let batch2 = q.flush_next().expect("flush2");
2679 q.requeue(batch2);
2680 q.mark_complete(ch);
2681 assert!(
2682 !q.has_flushable_work(),
2683 "throttled channel should not be flushable"
2684 );
2685
2686 // Manually expire the retry_after to simulate time passing.
2687 q.retry_after
2688 .insert(ch, Instant::now() - Duration::from_secs(1));
2689 assert!(
2690 q.has_flushable_work(),
2691 "expired throttle should be flushable"
2692 );
2693 }
2694
2695 #[test]
2696 fn test_requeue_dead_letters_after_max_retries() {

Callers

nothing calls this directly

Calls 6

make_queuedFunction · 0.85
pushMethod · 0.80
flush_nextMethod · 0.80
mark_completeMethod · 0.80
requeueMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected