Lines
100 %
Functions
Branches
use web::Config;
#[test]
fn test_config_structure() {
let config = Config {
site_url: "http://localhost:3000".to_string(),
redis_url: "redis://localhost:6379".to_string(),
access_token_max_age: 15,
refresh_token_max_age: 60,
ssh: web::config::SshConnectInfo {
hostname: "ssh.example.invalid".to_string(),
port: 2222,
host_fingerprint: "(test)".to_string(),
},
};
assert_eq!(config.site_url, "http://localhost:3000");
assert_eq!(config.redis_url, "redis://localhost:6379");
assert_eq!(config.access_token_max_age, 15);
assert_eq!(config.refresh_token_max_age, 60);
}
/// REDIS_URL is a deployment endpoint, so a value in the environment must beat
/// the seeded row — otherwise a fresh install crash-loops against
/// redis://127.0.0.1:6379/ until someone rewrites the row by hand.
fn env_supplies_the_redis_url_when_set() {
assert_eq!(
web::config::env_override(Some("redis://redis.redis.svc:6379/1".to_string())),
Some("redis://redis.redis.svc:6379/1".to_string()),
);
/// An unset key falls through to the configured row.
fn an_absent_key_does_not_override() {
assert_eq!(web::config::env_override(None), None);
/// A ConfigMap can carry an empty string. Taking it literally would replace
/// working configuration with a URL that cannot parse, so it counts as unset.
fn an_empty_key_counts_as_unset() {
assert_eq!(web::config::env_override(Some(String::new())), None);
assert_eq!(web::config::env_override(Some(" ".to_string())), None);