From 69d861a9ba472f1f95814b023d35d08f37be7e69 Mon Sep 17 00:00:00 2001 From: Jacob Gelman <3182119+ladvoc@users.noreply.github.com> Date: Fri, 19 Sep 2025 19:10:53 +1000 Subject: [PATCH] Allow passing test room options --- livekit/tests/common/e2e.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/livekit/tests/common/e2e.rs b/livekit/tests/common/e2e.rs index 676c758c4..5a71f0fe2 100644 --- a/livekit/tests/common/e2e.rs +++ b/livekit/tests/common/e2e.rs @@ -26,31 +26,39 @@ impl TestEnvironment { /// Creates the specified number of connections to a shared room for testing. pub async fn test_rooms(count: usize) -> Result)>> { + test_rooms_with_options((0..count).map(|_| RoomOptions::default())).await +} + +/// Creates multiple connections to a shared room for testing, one for each configuration. +pub async fn test_rooms_with_options( + options: impl IntoIterator, +) -> Result)>> { let test_env = TestEnvironment::from_env_or_defaults(); let room_name = format!("test_room_{}", create_random_uuid()); - let tokens = (0..count) + let tokens = options .into_iter() - .map(|id| -> Result { + .enumerate() + .map(|(id, options)| -> Result<(String, RoomOptions)> { let grants = VideoGrants { room_join: true, room: room_name.clone(), ..Default::default() }; - Ok(AccessToken::with_api_key(&test_env.api_key, &test_env.api_secret) + let token = AccessToken::with_api_key(&test_env.api_key, &test_env.api_secret) .with_ttl(Duration::from_secs(30 * 60)) // 30 minutes .with_grants(grants) .with_identity(&format!("p{}", id)) .to_jwt() - .context("Failed to generate JWT")?) + .context("Failed to generate JWT")?; + Ok((token, options)) }) .collect::>>()?; - let rooms = try_join_all(tokens.into_iter().map(|token| { + let rooms = try_join_all(tokens.into_iter().map(|(token, options)| { let server_url = test_env.server_url.clone(); async move { - let options = RoomOptions::default(); Room::connect(&server_url, &token, options).await.context("Failed to connect to room") } })) .await?; Ok(rooms) -} +} \ No newline at end of file