use lj_rust::conf::{Conf, DacFamily}; #[test] fn it_loads_a_valid_conf() { let result = Conf::new("tests/settings/valid"); assert!(result.is_ok()); } #[test] fn it_fails_invalid_conf() { let result = Conf::new("tests/settings/empty"); assert!(result.is_err()); } #[test] fn it_finds_struct_fields() { let config = match Conf::new("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"))); }