test(sysctl): add tests for the controller module

This commit is contained in:
Orhun Parmaksız 2021-12-18 15:18:10 +03:00
parent 53a6b0ecbf
commit 41dabbf217
No known key found for this signature in database
GPG key ID: F83424824B3E4B90

View file

@ -78,7 +78,7 @@ impl Sysctl {
parameters
}
/// Updates the parameters using the given list.
/// Updates the parameters internally using the given list.
///
/// Keeps the original values.
pub fn update_params(&mut self, mut parameters: Vec<Parameter>) {
@ -126,3 +126,21 @@ impl Sysctl {
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_sysctl_controller() -> Result<()> {
let config = Config::default();
let mut sysctl = Sysctl::init(config)?;
assert!(sysctl.get_parameter("kernel.hostname").is_some());
assert_eq!(
"Linux",
sysctl.get_parameters("ostype").first().unwrap().value
);
Ok(())
}
}