test: make the real-Redis TTL tests runnable against a rediss:// URL
The two REDIS_TEST_URL-gated tests could never have passed as written: a unit-test binary never runs main(), so no rustls crypto provider was installed and the TLS handshake to a rediss:// URL panicked before any command was sent. Install the provider in a helper inside the test module and reuse the same call main.rs already makes. Also fix a key-construction typo in the retry/DLQ test: the retry counter key embeds the message id, not the run id. Verified against the live Upstash instance: REDIS_TEST_URL=rediss://... cargo test --locked -- --ignored ttl ttl_claim_dedup_sets_the_exactly_requested_expiry ... ok ttl_consent_and_retry_landing_on_real_redis ... ok
This commit is contained in:
parent
7d6ea013b4
commit
d8e1226c76
|
|
@ -207,7 +207,7 @@ async fn main() -> Result<(), error::BotError> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn install_rustls_provider() -> bool {
|
||||
pub(crate) fn install_rustls_provider() -> bool {
|
||||
rustls::crypto::ring::default_provider()
|
||||
.install_default()
|
||||
.is_ok()
|
||||
|
|
|
|||
12
src/state.rs
12
src/state.rs
|
|
@ -1653,6 +1653,16 @@ mod real_redis_ttl_tests {
|
|||
format!("{}:{}", std::process::id(), unix_now())
|
||||
}
|
||||
|
||||
/// Unit-test binaries never run `main()`, so no rustls crypto provider is
|
||||
/// installed and the TLS handshake to a `rediss://` URL panics before any
|
||||
/// command is sent. Mirror the one-time setup in `main.rs`.
|
||||
fn require_tls_provider() {
|
||||
assert!(
|
||||
crate::install_rustls_provider(),
|
||||
"rustls needs a crypto provider before any Redis TLS client"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "requires REDIS_TEST_URL pointing at a reachable Redis"]
|
||||
async fn ttl_claim_dedup_sets_the_exactly_requested_expiry() {
|
||||
|
|
@ -1660,6 +1670,7 @@ mod real_redis_ttl_tests {
|
|||
eprintln!("skipped: REDIS_TEST_URL is not configured");
|
||||
return;
|
||||
};
|
||||
require_tls_provider();
|
||||
let state = RedisState::connect(url.to_str().expect("valid utf8 REDIS_TEST_URL"))
|
||||
.await
|
||||
.expect("REDIS_TEST_URL must be reachable");
|
||||
|
|
@ -1699,6 +1710,7 @@ mod real_redis_ttl_tests {
|
|||
eprintln!("skipped: REDIS_TEST_URL is not configured");
|
||||
return;
|
||||
};
|
||||
require_tls_provider();
|
||||
let state = RedisState::connect(url.to_str().expect("valid utf8 REDIS_TEST_URL"))
|
||||
.await
|
||||
.expect("REDIS_TEST_URL must be reachable");
|
||||
|
|
|
|||
Loading…
Reference in New Issue