From d31cd5615e16531152635a192bb0f5659536b748 Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Mon, 30 Nov 2026 00:53:05 +0800 Subject: [PATCH] Move cluster configuration test to integration tests --- crates/clusters/src/lib.rs | 43 ---------------------- crates/clusters/tests/deployment_config.rs | 41 +++++++++++++++++++++ 2 files changed, 41 insertions(+), 43 deletions(-) create mode 100644 crates/clusters/tests/deployment_config.rs diff --git a/crates/clusters/src/lib.rs b/crates/clusters/src/lib.rs index 4d30fce..6fe4767 100644 --- a/crates/clusters/src/lib.rs +++ b/crates/clusters/src/lib.rs @@ -227,46 +227,3 @@ fn sqlite_url(path: &str, read_only: bool) -> Result { let mode = if read_only { "ro" } else { "rwc" }; Ok(Address(format!("sqlite:{file}?mode={mode}"))) } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn named_cluster_requires_matching_addresses_and_redacts_credentials() { - let mut config = DeploymentConfig { - cluster: Some("regional".into()), - clusters: BTreeMap::from([( - "regional".into(), - Cluster { - driver: Driver::Postgres, - primary: "postgres://user:secret@primary/bedrock".into(), - replicas: vec!["postgresql://reader:secret@replica/bedrock".into()], - tls: Tls::VerifyFull, - max_connections: 5, - }, - )]), - ..DeploymentConfig::default() - }; - let resolved = config.resolve().unwrap(); - assert!( - resolved - .primary - .connection_string() - .ends_with("sslmode=verify-full") - ); - assert!( - resolved.replicas[0] - .connection_string() - .ends_with("sslmode=verify-full") - ); - assert!(!format!("{resolved:?}").contains("secret")); - - config.clusters.get_mut("regional").unwrap().replicas[0] = - "mysql://user:secret@replica/bedrock".into(); - assert!(matches!( - config.resolve(), - Err(ConfigError::Url("postgres")) - )); - } -} diff --git a/crates/clusters/tests/deployment_config.rs b/crates/clusters/tests/deployment_config.rs new file mode 100644 index 0000000..46bf1f0 --- /dev/null +++ b/crates/clusters/tests/deployment_config.rs @@ -0,0 +1,41 @@ +use std::collections::BTreeMap; + +use clusters::{Cluster, ConfigError, DeploymentConfig, Driver, Tls}; + +#[test] +fn named_cluster_requires_matching_addresses_and_redacts_credentials() { + let mut config = DeploymentConfig { + cluster: Some("regional".into()), + clusters: BTreeMap::from([( + "regional".into(), + Cluster { + driver: Driver::Postgres, + primary: "postgres://user:secret@primary/bedrock".into(), + replicas: vec!["postgresql://reader:secret@replica/bedrock".into()], + tls: Tls::VerifyFull, + max_connections: 5, + }, + )]), + ..DeploymentConfig::default() + }; + let resolved = config.resolve().unwrap(); + assert!( + resolved + .primary + .connection_string() + .ends_with("sslmode=verify-full") + ); + assert!( + resolved.replicas[0] + .connection_string() + .ends_with("sslmode=verify-full") + ); + assert!(!format!("{resolved:?}").contains("secret")); + + config.clusters.get_mut("regional").unwrap().replicas[0] = + "mysql://user:secret@replica/bedrock".into(); + assert!(matches!( + config.resolve(), + Err(ConfigError::Url("postgres")) + )); +}