返回 DeepSeek-TUI-2026
parity_protocol.rs
根目录 / crates / protocol / tests / parity_protocol.rs
1 use deepseek_protocol::{EventFrame, ThreadListParams, ThreadRequest, ThreadResumeParams};
2
3 #[test]
4 fn thread_resume_params_round_trip() {
5 let request = ThreadRequest::Resume(ThreadResumeParams {
6 thread_id: "thread-123".to_string(),
7 history: None,
8 path: None,
9 model: Some("deepseek-v4-pro".to_string()),
10 model_provider: Some("deepseek".to_string()),
11 cwd: None,
12 approval_policy: Some("on-request".to_string()),
13 sandbox: Some("workspace-write".to_string()),
14 config: None,
15 base_instructions: Some("base".to_string()),
16 developer_instructions: Some("dev".to_string()),
17 personality: Some("default".to_string()),
18 persist_extended_history: true,
19 });
20
21 let encoded = serde_json::to_string(&request).expect("serialize request");
22 let decoded: ThreadRequest = serde_json::from_str(&encoded).expect("deserialize request");
23 match decoded {
24 ThreadRequest::Resume(params) => {
25 assert_eq!(params.thread_id, "thread-123");
26 assert_eq!(params.model.as_deref(), Some("deepseek-v4-pro"));
27 assert!(params.persist_extended_history);
28 }
29 other => panic!("unexpected request: {other:?}"),
30 }
31 }
32
33 #[test]
34 fn thread_list_params_defaults_are_serializable() {
35 let request = ThreadRequest::List(ThreadListParams {
36 include_archived: false,
37 limit: Some(20),
38 });
39 let encoded = serde_json::to_string_pretty(&request).expect("serialize list request");
40 assert!(encoded.contains("include_archived"));
41 }
42
43 #[test]
44 fn event_frame_serialization_contains_expected_tag() {
45 let frame = EventFrame::TurnComplete {
46 turn_id: "turn-1".to_string(),
47 };
48 let encoded = serde_json::to_string(&frame).expect("serialize frame");
49 assert!(encoded.contains("turn_complete"));
50 }
51
51 lines RUST