MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_cancel_all

Function test_cancel_all

core/src/hitl.rs:918–946  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

916
917 #[tokio::test]
918 async fn test_cancel_all() {
919 let (event_tx, _) = broadcast::channel(100);
920 let manager = ConfirmationManager::new(ConfirmationPolicy::enabled(), event_tx);
921
922 // Request multiple confirmations
923 let rx1 = manager
924 .request_confirmation("tool-1", "bash", &serde_json::json!({}))
925 .await;
926 let rx2 = manager
927 .request_confirmation("tool-2", "write", &serde_json::json!({}))
928 .await;
929 let rx3 = manager
930 .request_confirmation("tool-3", "edit", &serde_json::json!({}))
931 .await;
932
933 assert_eq!(manager.pending_count().await, 3);
934
935 // Cancel all
936 let cancelled_count = manager.cancel_all().await;
937 assert_eq!(cancelled_count, 3);
938 assert_eq!(manager.pending_count().await, 0);
939
940 // All responses should indicate cancellation
941 for rx in [rx1, rx2, rx3] {
942 let response = rx.await.unwrap();
943 assert!(!response.approved);
944 assert_eq!(response.reason, Some("Confirmation cancelled".to_string()));
945 }
946 }
947
948 // ========================================================================
949 // Timeout Tests

Callers

nothing calls this directly

Calls 2

request_confirmationMethod · 0.45
cancel_allMethod · 0.45

Tested by

no test coverage detected