lj_rust/tests/test_conf.rs
2023-06-03 23:27:12 +02:00

33 lines
865 B
Rust

use lj_rust::conf::{load_config, DacFamily};
#[test]
fn it_loads_a_valid_conf() {
let result = load_config("tests/settings/valid");
assert!(result.is_ok());
}
#[test]
fn it_fails_invalid_conf() {
let result = load_config("tests/settings/empty");
assert!(result.is_err());
}
#[test]
fn it_finds_struct_fields() {
let config = match load_config("tests/settings/valid") {
Ok(c) => c,
Err(err) => {
panic!("Unable to load config file: {:?}", err)
}
};
assert_eq!(config.laser_id, u8::from(0));
assert_eq!(config.debug, true);
assert_eq!(config.redis_url, String::from("127.0.0.1"));
assert!(match config.dac_family {
DacFamily::Helios => true,
_ => false,
});
assert_eq!(config.dac_id, Some(0));
assert_eq!(config.dac_url, Some(String::from("192.168.1.68")));
}