mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-12 14:10:19 +08:00
test: align concurrency fixtures with runtime boundaries
Centralize isolated Redis test connections in the shared test module, use the canonical Claude Messages format, and correct the borrowed entry comparison.
This commit is contained in:
@@ -973,8 +973,8 @@ mod tests {
|
||||
let mut event = wire_billing_event("wire-claude-cache");
|
||||
event.data.model = "claude-sonnet-4-6".to_string();
|
||||
event.data.target_model = Some("claude-sonnet-4-6".to_string());
|
||||
event.data.api_format = Some("claude:chat".to_string());
|
||||
event.data.endpoint_api_format = Some("claude:chat".to_string());
|
||||
event.data.api_format = Some("claude:messages".to_string());
|
||||
event.data.endpoint_api_format = Some("claude:messages".to_string());
|
||||
event.data.provider_request_body = None;
|
||||
event.data.provider_request_body_state = Some(UsageBodyCaptureState::Disabled);
|
||||
event.data.cache_creation_input_tokens = Some(200);
|
||||
|
||||
@@ -1995,6 +1995,14 @@ mod tests {
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
|
||||
async fn redis_test_connection(url: &str) -> ::redis::aio::MultiplexedConnection {
|
||||
::redis::Client::open(url)
|
||||
.expect("test Redis client")
|
||||
.get_multiplexed_async_connection()
|
||||
.await
|
||||
.expect("test Redis connection")
|
||||
}
|
||||
|
||||
mod stream_receive {
|
||||
include!("redis/stream_receive_tests.rs");
|
||||
}
|
||||
|
||||
@@ -14,11 +14,7 @@ async fn transfer_runtime(
|
||||
);
|
||||
return None;
|
||||
};
|
||||
let mut admin = ::redis::Client::open(server.redis_url.clone())
|
||||
.expect("transfer admin client")
|
||||
.get_multiplexed_async_connection()
|
||||
.await
|
||||
.expect("transfer admin connection");
|
||||
let mut admin = redis_test_connection(&server.redis_url).await;
|
||||
::redis::cmd("ACL")
|
||||
.arg("SETUSER")
|
||||
.arg(TRANSFER_USER)
|
||||
@@ -175,7 +171,7 @@ async fn assert_transfer_source_unchanged(
|
||||
) {
|
||||
assert_eq!(
|
||||
transfer_entries(admin, source).await.as_slice(),
|
||||
std::slice::from_ref(&entry)
|
||||
std::slice::from_ref(entry)
|
||||
);
|
||||
let pending = transfer_pending(admin, source).await;
|
||||
assert_eq!(pending.len(), 1);
|
||||
|
||||
@@ -28,11 +28,7 @@ async fn receive_runtime(
|
||||
);
|
||||
return None;
|
||||
};
|
||||
let mut admin = ::redis::Client::open(server.redis_url.clone())
|
||||
.expect("test admin client")
|
||||
.get_multiplexed_async_connection()
|
||||
.await
|
||||
.expect("test admin connection");
|
||||
let mut admin = redis_test_connection(&server.redis_url).await;
|
||||
::redis::cmd("ACL")
|
||||
.arg("SETUSER")
|
||||
.arg("stream-reader")
|
||||
|
||||
@@ -46,11 +46,7 @@ impl Fixture {
|
||||
eprintln!("usage cleanup {protocol} skipped: isolated Redis unavailable");
|
||||
return None;
|
||||
};
|
||||
let mut admin = ::redis::Client::open(server.redis_url.clone())
|
||||
.unwrap()
|
||||
.get_multiplexed_async_connection()
|
||||
.await
|
||||
.unwrap();
|
||||
let mut admin = redis_test_connection(&server.redis_url).await;
|
||||
::redis::cmd("ACL")
|
||||
.arg("SETUSER")
|
||||
.arg("usage-cleanup")
|
||||
@@ -1072,14 +1068,11 @@ async fn redis_usage_cleanup_copy_refuses_existing_temporary_and_denied_expirati
|
||||
.query_async::<()>(&mut fixture.admin)
|
||||
.await
|
||||
.unwrap();
|
||||
let mut connection = ::redis::Client::open(format!(
|
||||
let mut connection = redis_test_connection(&format!(
|
||||
"redis://usage-cleanup:usage-cleanup-test-password@127.0.0.1:{}/6",
|
||||
fixture._server.port,
|
||||
))
|
||||
.unwrap()
|
||||
.get_multiplexed_async_connection()
|
||||
.await
|
||||
.unwrap();
|
||||
.await;
|
||||
let script = ::redis::Script::new(include_str!("usage_copy.lua"));
|
||||
let result = script
|
||||
.key(source)
|
||||
|
||||
Reference in New Issue
Block a user