Skip to content

Commit f0b2eba

Browse files
committed
Change test case to match error via types, not strings
Minor followup to the previous change; part of the idea of having the error types here is so we can *also* dig through the `SkopeoSpawnError` and precisely match against the `std::io::ErrorKind::NotFound`, and not rely on its stringified form. This is what we'd expect other callers to do. This also avoids a double-match. Signed-off-by: Colin Walters <[email protected]>
1 parent bb0ba4d commit f0b2eba

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/imageproxy.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,12 @@ mod tests {
701701
};
702702
config.skopeo_cmd = Some(Command::new("no-skopeo"));
703703

704-
let res = ImageProxy::new_with_config(config).await;
705-
assert!(matches!(res, Err(Error::SkopeoSpawnError(_))));
706-
assert_eq!(
707-
res.err().unwrap().to_string(),
708-
"skopeo spawn error: No such file or directory (os error 2)"
709-
);
704+
match ImageProxy::new_with_config(config).await {
705+
Ok(_) => panic!("Expected an error"),
706+
Err(Error::SkopeoSpawnError(e)) => {
707+
assert_eq!(e.kind(), std::io::ErrorKind::NotFound);
708+
}
709+
Err(e) => panic!("Unexpected error {e}"),
710+
}
710711
}
711712
}

0 commit comments

Comments
 (0)