MCPcopy Create free account
hub / github.com/clawshell/clawshell / test_sse_stream_ignores_events_without_usage

Function test_sse_stream_ignores_events_without_usage

src/translate.rs:1081–1102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1079
1080 #[test]
1081 fn test_sse_stream_ignores_events_without_usage() {
1082 let stats = Arc::new(Stats::new(None));
1083 let scanner = Arc::new(DlpScanner::new(&[], false).unwrap());
1084 let sse = "data: {\"choices\":[{\"delta\":{\"content\":\"hello\"}}]}\n\
1085 data: {\"choices\":[{\"delta\":{\"content\":\" world\"}}]}\n\
1086 data: [DONE]\n";
1087 let body = Body::from(sse);
1088 let wrapped = wrap_body_with_dlp_sse_stream(body, scanner, stats.clone());
1089
1090 let rt = tokio::runtime::Builder::new_current_thread()
1091 .build()
1092 .unwrap();
1093 rt.block_on(async {
1094 use http_body_util::BodyExt;
1095 wrapped.collect().await.unwrap();
1096 });
1097
1098 let snap = stats.snapshot();
1099 assert_eq!(snap.prompt_tokens_total, 0);
1100 assert_eq!(snap.completion_tokens_total, 0);
1101 assert_eq!(snap.total_tokens_total, 0);
1102 }
1103}

Callers

nothing calls this directly

Calls 2

snapshotMethod · 0.80

Tested by

no test coverage detected