//! `[gateway]` in `brokerd.toml`: absent means Mattermost approvals are off; an empty socket is //! the default under `home` (M4b spec, section 3). Do not edit. use std::path::PathBuf; use brokerd::config::Config; fn parse(text: &str) -> Config { Config::parse(&format!("[paths]\nhome = \"/srv/bx\"\n{text}")).unwrap() } #[test] fn without_the_section_approvals_stay_in_bxctl() { let config = parse(""); assert_eq!(config.gateway, None); assert_eq!(config.gateway_socket(), None); } #[test] fn an_empty_section_or_socket_is_the_default() { let default = Some(PathBuf::from("/srv/bx/run/gateway/gateway.sock")); assert_eq!(parse("[gateway]\n").gateway_socket(), default); assert_eq!( parse("[gateway]\nsocket = \"\"\n").gateway_socket(), default ); } #[test] fn a_socket_path_is_used_as_given() { let config = parse("[gateway]\nsocket = \"/run/bx/gw.sock\"\n"); assert_eq!( config.gateway_socket(), Some(PathBuf::from("/run/bx/gw.sock")) ); } #[test] fn unknown_keys_are_errors() { assert!(Config::parse("[gateway]\nsockets = \"/x\"\n").is_err()); assert!(Config::parse("[gateway]\nsocket = \"/x\"\nenabled = true\n").is_err()); assert!(Config::parse("[gatewy]\nsocket = \"/x\"\n").is_err()); }