disks/zfs: fix test input and enforce check for config key
we test for the config key in the API so it makes sense to have as test here too. Actually it would be better if we'd have a expect Value defined here and enforce that it matches, but better than nothing. Fix the input for test 1, where tabs got replaced by spaces, as else it fails Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
2440eaa2df
commit
d64226efee
|
@ -372,14 +372,20 @@ pub fn zpool_status(pool: &str) -> Result<Vec<(String, String)>, Error> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn test_parse(output: &str) -> Result<(), Error> {
|
fn test_parse(output: &str) -> Result<(), Error> {
|
||||||
|
let mut found_config = false;
|
||||||
|
|
||||||
for (k, v) in parse_zpool_status(&output)? {
|
for (k, v) in parse_zpool_status(&output)? {
|
||||||
println!("{} => {}", k,v);
|
println!("<{}> => '{}'", k, v);
|
||||||
if k == "config" {
|
if k == "config" {
|
||||||
let vdev_list = parse_zpool_status_config_tree(&v)?;
|
let vdev_list = parse_zpool_status_config_tree(&v)?;
|
||||||
let _tree = vdev_list_to_tree(&vdev_list);
|
let _tree = vdev_list_to_tree(&vdev_list);
|
||||||
found_config = true;
|
found_config = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !found_config {
|
||||||
|
bail!("got zpool status without config key");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue