46 lines
1.4 KiB
Rust
46 lines
1.4 KiB
Rust
use std::collections::BTreeMap;
|
|
|
|
use clusters::{Address, Cluster, ConfigError, DeploymentConfig, Driver, Tls};
|
|
|
|
#[test]
|
|
fn address_debug_formats_the_inner_string() {
|
|
let value = "bedrock.sqlite3";
|
|
assert_eq!(format!("{:?}", Address::from(value)), format!("{value:?}"));
|
|
}
|
|
|
|
#[test]
|
|
fn named_cluster_requires_matching_addresses() {
|
|
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")
|
|
);
|
|
config.clusters.get_mut("regional").unwrap().replicas[0] =
|
|
"mysql://user:secret@replica/bedrock".into();
|
|
assert!(matches!(
|
|
config.resolve(),
|
|
Err(ConfigError::Url("postgres"))
|
|
));
|
|
}
|