diff --git a/api/tests/sse.rs b/api/tests/sse.rs index a72b833..7612dab 100644 --- a/api/tests/sse.rs +++ b/api/tests/sse.rs @@ -32,7 +32,7 @@ pub async fn connect_sse(client: &Client) -> impl Stream( - mut stream: impl Stream> + Unpin, + stream: &mut (impl Stream> + Unpin), wanted_event: &str, ) -> T { let mut buffer = String::new(); @@ -69,7 +69,7 @@ pub async fn read_event( async fn sends_events_on_add_todo() { let client = get_client().await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; let todo_uuid = Uuid::new_v4(); client @@ -84,7 +84,7 @@ async fn sends_events_on_add_todo() { })) .await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos")) + let todos: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "todos")) .await .unwrap(); @@ -109,7 +109,7 @@ async fn sends_events_on_update_todo() { })) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client .update_todo_json(json!({ @@ -121,7 +121,7 @@ async fn sends_events_on_update_todo() { })) .await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos")) + let todos: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "todos")) .await .unwrap(); assert_eq!(todos.len(), 1); @@ -146,11 +146,11 @@ async fn sends_todo_events_on_remove_todo() { })) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client.delete_todo_json(todo_uuid).await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos")) + let todos: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "todos")) .await .unwrap(); assert_eq!(todos.len(), 0); @@ -173,13 +173,16 @@ async fn sends_deleted_events_on_remove_todo() { })) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client.delete_todo_json(todo_uuid).await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos-deleted")) - .await - .unwrap(); + let todos: Vec = timeout( + Duration::from_secs(2), + read_event(&mut stream, "todos-deleted"), + ) + .await + .unwrap(); assert_eq!(todos.len(), 1); } @@ -200,18 +203,17 @@ async fn sends_todo_events_on_reactivate_todo() { })) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client.delete_todo_json(todo_uuid).await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos")) + let todos: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "todos")) .await .unwrap(); assert_eq!(todos.len(), 0); - let stream = connect_sse(&client).await; client.reactivate_todo(todo_uuid).await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos")) + let todos: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "todos")) .await .unwrap(); assert_eq!(todos.len(), 1); @@ -234,20 +236,25 @@ async fn sends_deleted_events_on_reactivate_todo() { })) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client.delete_todo_json(todo_uuid).await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos-deleted")) - .await - .unwrap(); + let todos: Vec = timeout( + Duration::from_secs(2), + read_event(&mut stream, "todos-deleted"), + ) + .await + .unwrap(); assert_eq!(todos.len(), 1); - let stream = connect_sse(&client).await; client.reactivate_todo(todo_uuid).await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos-deleted")) - .await - .unwrap(); + let todos: Vec = timeout( + Duration::from_secs(2), + read_event(&mut stream, "todos-deleted"), + ) + .await + .unwrap(); assert_eq!(todos.len(), 0); } @@ -268,11 +275,11 @@ async fn sends_events_on_check_todo() { })) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client.check_todo(todo_uuid).await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos")) + let todos: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "todos")) .await .unwrap(); assert_eq!(todos.len(), 1); @@ -297,11 +304,11 @@ async fn sends_events_on_check_remove_todo() { client.check_todo(todo_uuid).await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client.remove_check_todo(todo_uuid).await; - let todos: Vec = timeout(Duration::from_secs(2), read_event(stream, "todos")) + let todos: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "todos")) .await .unwrap(); assert_eq!(todos.len(), 1); @@ -311,7 +318,7 @@ async fn sends_events_on_check_remove_todo() { async fn sends_events_on_add_tag() { let client = get_client().await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; let tag_uuid = Uuid::new_v4(); client @@ -325,7 +332,7 @@ async fn sends_events_on_add_tag() { )) .await; - let tags: Vec = timeout(Duration::from_secs(2), read_event(stream, "tags")) + let tags: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "tags")) .await .unwrap(); @@ -349,7 +356,7 @@ async fn sends_events_on_update_tag() { )) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client .update_tag_json(json!({ @@ -360,7 +367,7 @@ async fn sends_events_on_update_tag() { })) .await; - let tags: Vec = timeout(Duration::from_secs(2), read_event(stream, "tags")) + let tags: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "tags")) .await .unwrap(); @@ -385,11 +392,11 @@ async fn sends_events_on_remove_tag() { )) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client.delete_tag_json(tag_uuid).await; - let tags: Vec = timeout(Duration::from_secs(2), read_event(stream, "tags")) + let tags: Vec = timeout(Duration::from_secs(2), read_event(&mut stream, "tags")) .await .unwrap(); @@ -400,7 +407,7 @@ async fn sends_events_on_remove_tag() { async fn sends_events_on_add_category() { let client = get_client().await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; let category_uuid = Uuid::new_v4(); client @@ -414,10 +421,12 @@ async fn sends_events_on_add_category() { )) .await; - let categories: Vec = - timeout(Duration::from_secs(2), read_event(stream, "categories")) - .await - .unwrap(); + let categories: Vec = timeout( + Duration::from_secs(2), + read_event(&mut stream, "categories"), + ) + .await + .unwrap(); assert_eq!(categories.len(), 1); assert_eq!(categories.first().unwrap().uuid, category_uuid); @@ -439,7 +448,7 @@ async fn sends_events_on_update_category() { )) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client .update_category_json(json!({ @@ -450,10 +459,12 @@ async fn sends_events_on_update_category() { })) .await; - let categories: Vec = - timeout(Duration::from_secs(2), read_event(stream, "categories")) - .await - .unwrap(); + let categories: Vec = timeout( + Duration::from_secs(2), + read_event(&mut stream, "categories"), + ) + .await + .unwrap(); assert_eq!(categories.len(), 1); assert_eq!(categories.first().unwrap().uuid, category_uuid); assert_eq!(categories.first().unwrap().name, "Updated Category"); @@ -475,14 +486,16 @@ async fn sends_events_on_remove_category() { )) .await; - let stream = connect_sse(&client).await; + let mut stream = connect_sse(&client).await; client.delete_category_json(category_uuid).await; - let categories: Vec = - timeout(Duration::from_secs(2), read_event(stream, "categories")) - .await - .unwrap(); + let categories: Vec = timeout( + Duration::from_secs(2), + read_event(&mut stream, "categories"), + ) + .await + .unwrap(); assert_eq!(categories.len(), 0); }