#![cfg(feature = "daemon")]
#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]
use zerodds_websocket_bridge::daemon::config::DaemonConfig;
const EXAMPLE_YAML: &str = include_str!("../../../packaging/linux/configs/ws-bridged.yaml.example");
#[test]
fn example_yaml_parses_without_error() {
let res = DaemonConfig::load_from_str(EXAMPLE_YAML);
assert!(
res.is_ok(),
"ws-bridged.yaml.example does not parse: {:?}",
res.err()
);
}
#[test]
fn example_yaml_key_fields_match_intent() {
let cfg = DaemonConfig::load_from_str(EXAMPLE_YAML)
.expect("example yaml must parse — see example_yaml_parses_without_error");
assert_eq!(cfg.listen, "0.0.0.0:8080");
assert_eq!(cfg.domain, 0);
assert_eq!(cfg.log_level, "info");
assert!(!cfg.tls_enabled);
assert_eq!(cfg.tls_cert_file, "/etc/zerodds/certs/ws-bridged.crt");
assert_eq!(cfg.tls_key_file, "/etc/zerodds/certs/ws-bridged.key");
assert_eq!(cfg.auth_mode, "none");
assert!(cfg.auth_bearer_token.is_none());
assert!(!cfg.metrics_enabled);
assert_eq!(cfg.metrics_addr, "127.0.0.1:9091");
assert_eq!(
cfg.topics.len(),
1,
"example should show exactly one demo topic"
);
let t = &cfg.topics[0];
assert_eq!(t.name, "Chat::Message");
assert_eq!(t.type_name, "Chat::Message");
assert_eq!(t.direction, "bidir");
assert_eq!(t.ws_path, "/chat");
assert_eq!(t.reliability, "reliable");
assert_eq!(t.durability, "volatile");
assert_eq!(t.history_depth, 10);
}