|
1 | 1 | // Integration tests for ss-proxy server |
2 | 2 | // Tests HTTP/HTTPS and WebSocket proxy functionality |
3 | 3 |
|
4 | | -use tokio::time::Duration; |
5 | | -use std::process::{Command, Child}; |
6 | | -use std::sync::{Once, Mutex}; |
| 4 | +use std::process::{Child, Command}; |
7 | 5 | use std::sync::OnceLock; |
| 6 | +use std::sync::{Mutex, Once}; |
| 7 | +use tokio::time::Duration; |
8 | 8 |
|
9 | 9 | static INIT: Once = Once::new(); |
10 | 10 | static SERVER_PROCESS: OnceLock<Mutex<Option<Child>>> = OnceLock::new(); |
@@ -57,7 +57,8 @@ fn setup_test_server() { |
57 | 57 | .spawn() |
58 | 58 | .expect("Failed to start server"); |
59 | 59 |
|
60 | | - SERVER_PROCESS.set(Mutex::new(Some(server))) |
| 60 | + SERVER_PROCESS |
| 61 | + .set(Mutex::new(Some(server))) |
61 | 62 | .expect("Failed to set server process"); |
62 | 63 |
|
63 | 64 | // Wait for server to start |
@@ -155,7 +156,10 @@ async fn test_http_proxy_with_query_params() { |
155 | 156 |
|
156 | 157 | let client = reqwest::Client::new(); |
157 | 158 | let response = client |
158 | | - .get(format!("{}/test-http/get?foo=bar&hello=world", get_base_url())) |
| 159 | + .get(format!( |
| 160 | + "{}/test-http/get?foo=bar&hello=world", |
| 161 | + get_base_url() |
| 162 | + )) |
159 | 163 | .send() |
160 | 164 | .await |
161 | 165 | .expect("Failed to send request"); |
@@ -222,8 +226,8 @@ async fn test_inactive_session() { |
222 | 226 |
|
223 | 227 | #[tokio::test] |
224 | 228 | async fn test_websocket_echo() { |
| 229 | + use futures_util::{SinkExt, StreamExt}; |
225 | 230 | use tokio_tungstenite::connect_async; |
226 | | - use futures_util::{StreamExt, SinkExt}; |
227 | 231 | use tokio_tungstenite::tungstenite::Message; |
228 | 232 |
|
229 | 233 | setup_test_server(); |
@@ -260,8 +264,8 @@ async fn test_websocket_echo() { |
260 | 264 |
|
261 | 265 | #[tokio::test] |
262 | 266 | async fn test_websocket_binary_message() { |
| 267 | + use futures_util::{SinkExt, StreamExt}; |
263 | 268 | use tokio_tungstenite::connect_async; |
264 | | - use futures_util::{StreamExt, SinkExt}; |
265 | 269 | use tokio_tungstenite::tungstenite::Message; |
266 | 270 |
|
267 | 271 | setup_test_server(); |
@@ -305,13 +309,16 @@ async fn test_websocket_session_not_found() { |
305 | 309 | // Try to connect to non-existent session |
306 | 310 | let result = connect_async(format!("{}/ws/nonexistent-session", get_ws_base_url())).await; |
307 | 311 |
|
308 | | - assert!(result.is_err(), "Connection should fail for non-existent session"); |
| 312 | + assert!( |
| 313 | + result.is_err(), |
| 314 | + "Connection should fail for non-existent session" |
| 315 | + ); |
309 | 316 | } |
310 | 317 |
|
311 | 318 | #[tokio::test] |
312 | 319 | async fn test_websocket_multiple_messages() { |
| 320 | + use futures_util::{SinkExt, StreamExt}; |
313 | 321 | use tokio_tungstenite::connect_async; |
314 | | - use futures_util::{StreamExt, SinkExt}; |
315 | 322 | use tokio_tungstenite::tungstenite::Message; |
316 | 323 |
|
317 | 324 | setup_test_server(); |
|
0 commit comments