Add a couple of unit test.

This commit is contained in:
Herbert Wolverson 2023-04-05 16:36:10 +00:00
parent eb9b32ef65
commit c9a443f77b

View File

@ -220,3 +220,23 @@ pub enum EtcLqosError {
#[error("Unable to write to /etc/lqos.conf")] #[error("Unable to write to /etc/lqos.conf")]
WriteFail, WriteFail,
} }
#[cfg(test)]
mod test {
const EXAMPLE_LQOS_CONF: &str = include_str!("../../../lqos.example");
#[test]
fn round_trip_toml() {
let doc = EXAMPLE_LQOS_CONF.parse::<toml_edit::Document>().unwrap();
let reserialized = doc.to_string();
assert_eq!(EXAMPLE_LQOS_CONF, reserialized);
}
#[test]
fn add_node_id() {
let mut doc = EXAMPLE_LQOS_CONF.parse::<toml_edit::Document>().unwrap();
doc["node_id"] = toml_edit::value("test");
let reserialized = doc.to_string();
assert!(reserialized.contains("node_id = \"test\""));
}
}