lj_rust/tests/test_conf.rs

35 lines
922 B
Rust
Raw Normal View History

2023-06-04 15:33:28 +00:00
use lj_rust::conf::{Conf, DacFamily, HeliosConf, EtherDreamConf};
2023-06-03 16:43:04 +00:00
#[test]
2023-06-03 21:27:12 +00:00
fn it_loads_a_valid_conf() {
2023-06-04 10:08:44 +00:00
let result = Conf::new("tests/settings/valid");
2023-06-03 21:27:12 +00:00
assert!(result.is_ok());
}
#[test]
fn it_fails_invalid_conf() {
2023-06-04 10:08:44 +00:00
let result = Conf::new("tests/settings/empty");
2023-06-03 21:27:12 +00:00
assert!(result.is_err());
}
#[test]
fn it_finds_struct_fields() {
2023-06-04 15:33:28 +00:00
let config = Conf::new("tests/settings/valid").unwrap();
assert_eq!(config.laser_id, 0);
2023-06-03 21:27:12 +00:00
assert_eq!(config.debug, true);
2023-06-04 15:33:28 +00:00
assert_eq!(config.redis_url, "redis://127.0.0.1:6379/");
assert!(match config.dac {
DacFamily::Helios(HeliosConf { id: 0 }) => true,
_ => false,
});
}
#[test]
fn it_finds_etherdream_fields() {
let config = Conf::new("tests/settings/valid_etherdream").unwrap();
assert!(match config.dac {
2023-07-16 18:26:45 +00:00
DacFamily::Etherdream(EtherDreamConf { ip }) if ip == "192.168.1.68" => true,
2023-06-03 21:27:12 +00:00
_ => false,
});
}