mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-15 13:58:55 +00:00
libs: Fix test_get_uds_with_sid_with_zero
Test case for `get_uds_with_sid` with an empty run directory would not hit the 0 match arm, i.e. "sandbox with the provided prefix {short_id:?} is not found", because `get_uds_with_sid` will try to create the directory with provided short id before detecting `target_id`. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
@@ -158,22 +158,21 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_uds_with_sid_with_zero() {
|
fn test_get_uds_with_sid_with_zero() {
|
||||||
let result = get_uds_with_sid("acdsdfe", KATA_PATH);
|
let run_path = tempdir().unwrap();
|
||||||
assert!(result.is_err());
|
let result = get_uds_with_sid("acdsdfe", &run_path.path().display().to_string());
|
||||||
if let Err(err) = result {
|
assert!(result.is_ok());
|
||||||
let left = format!("{:?}", err.to_string());
|
|
||||||
let left_unquoted = &left[1..left.len() - 1];
|
|
||||||
let left_unescaped = left_unquoted.replace("\\\"", "\"");
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
left_unescaped,
|
result.unwrap(),
|
||||||
format!(
|
format!(
|
||||||
"sandbox with the provided prefix {:?} is not found",
|
"unix://{}",
|
||||||
"acdsdfe"
|
run_path
|
||||||
|
.path()
|
||||||
|
.join("acdsdfe")
|
||||||
|
.join(SHIM_MGMT_SOCK_NAME)
|
||||||
|
.display()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_uds_with_sid_with_invalid() {
|
fn test_get_uds_with_sid_with_invalid() {
|
||||||
|
Reference in New Issue
Block a user