From aef3ab8f3292b7c25d3c5dc5ecbc05f9e86fe218 Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Thu, 14 May 2026 22:54:11 +0800 Subject: [PATCH] libs: Fix shim-interface tests after removing create_dir_all Two tests relied on the side-effect of create_dir_all (removed in the previous commit) to pass: (1) test_get_uds_with_sid_ok: use a directory name that actually starts with the search prefix so prefix matching works without creating dirs. (2) test_get_uds_with_sid_with_zero: assert Err on zero matches instead of Ok, matching the corrected lookup behavior. Signed-off-by: Alex Lyn --- src/libs/shim-interface/src/lib.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/libs/shim-interface/src/lib.rs b/src/libs/shim-interface/src/lib.rs index 90439b4733..12813d81eb 100644 --- a/src/libs/shim-interface/src/lib.rs +++ b/src/libs/shim-interface/src/lib.rs @@ -130,7 +130,7 @@ mod tests { #[test] fn test_get_uds_with_sid_ok() { let run_path = tempdir().unwrap(); - let dir = run_path.path().join("aata98654dangboxpath1"); + let dir = run_path.path().join("kata98654sandboxpath1"); fs::create_dir_all(dir.as_path()).unwrap(); let result = get_uds_with_sid("kata", &run_path.path().display().to_string()); @@ -141,7 +141,7 @@ mod tests { "unix://{}", run_path .path() - .join("kata") + .join("kata98654sandboxpath1") .join(SHIM_MGMT_SOCK_NAME) .display() ) @@ -152,18 +152,9 @@ mod tests { fn test_get_uds_with_sid_with_zero() { let run_path = tempdir().unwrap(); let result = get_uds_with_sid("acdsdfe", &run_path.path().display().to_string()); - assert!(result.is_ok()); - assert_eq!( - result.unwrap(), - format!( - "unix://{}", - run_path - .path() - .join("acdsdfe") - .join(SHIM_MGMT_SOCK_NAME) - .display() - ) - ) + assert!(result.is_err()); + let err_msg = result.unwrap_err().to_string(); + assert!(err_msg.contains("is not found")); } #[test]