diff --git a/src/app.rs b/src/app.rs index 2ea8072..5de3d47 100644 --- a/src/app.rs +++ b/src/app.rs @@ -42,18 +42,10 @@ fn template_env() -> &'static Environment<'static> { }) } -#[derive(Serialize, Deserialize, Debug, Clone)] -#[serde(tag = "type")] -enum ClientMessage { - Ping, - RequestRefresh, -} - #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[serde(tag = "type")] enum ServerMessage { Reload, - Pong, } use std::collections::HashMap; @@ -682,13 +674,7 @@ async fn handle_websocket(socket: WebSocket, state: SharedMarkdownState) { let recv_task = tokio::spawn(async move { while let Some(msg) = receiver.next().await { match msg { - Ok(Message::Text(text)) => { - if let Ok(client_msg) = serde_json::from_str::(&text) { - match client_msg { - ClientMessage::Ping | ClientMessage::RequestRefresh => {} - } - } - } + Ok(Message::Text(_)) => {} Ok(Message::Close(_)) => break, _ => {} } @@ -1017,18 +1003,7 @@ mod tests { ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after file modification"); - } - } - Err(_) => { - panic!("Timeout waiting for WebSocket update after file modification"); - } - } + update_result.expect("Timeout waiting for WebSocket update after file modification"); } #[tokio::test] @@ -1459,18 +1434,7 @@ classDiagram ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after file modification"); - } - } - Err(_) => { - panic!("Timeout waiting for WebSocket update after file modification"); - } - } + update_result.expect("Timeout waiting for WebSocket update after file modification"); } #[tokio::test] @@ -1490,18 +1454,7 @@ classDiagram ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after new file creation"); - } - } - Err(_) => { - panic!("Timeout waiting for WebSocket update after new file creation"); - } - } + update_result.expect("Timeout waiting for WebSocket update after new file creation"); let response = server.get("/test1.md").await; assert_eq!(response.status_code(), 200); @@ -1701,18 +1654,7 @@ classDiagram ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after temp file rename"); - } - } - Err(_) => { - panic!("Timeout waiting for WebSocket update after temp file rename"); - } - } + update_result.expect("Timeout waiting for WebSocket update after temp file rename"); let final_response = server.get("/").await; assert_eq!(final_response.status_code(), 200); @@ -1761,20 +1703,9 @@ classDiagram ) .await; - match update_result { - Ok(update_message) => { - if let ServerMessage::Reload = update_message { - // Success - } else { - panic!("Expected Reload message after temp file rename in directory mode"); - } - } - Err(_) => { - panic!( - "Timeout waiting for WebSocket update after temp file rename in directory mode" - ); - } - } + update_result.expect( + "Timeout waiting for WebSocket update after temp file rename in directory mode", + ); let final_response = server.get("/test1.md").await; assert_eq!(final_response.status_code(), 200);