From 8372fa992346853bea6d17ee51a16f777e821bf3 Mon Sep 17 00:00:00 2001 From: Kazuki Massaki Date: Wed, 4 Dec 2024 14:21:54 +0900 Subject: [PATCH] change the expected value to the capability generation error Signed-off-by: Kazuki Massaki Signed-off-by: kazuki.massaki --- .../process_capabilities_fail_test.rs | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/tests/contest/contest/src/tests/process_capabilities_fail/process_capabilities_fail_test.rs b/tests/contest/contest/src/tests/process_capabilities_fail/process_capabilities_fail_test.rs index 9062f0c9e..9f8d288d0 100644 --- a/tests/contest/contest/src/tests/process_capabilities_fail/process_capabilities_fail_test.rs +++ b/tests/contest/contest/src/tests/process_capabilities_fail/process_capabilities_fail_test.rs @@ -1,18 +1,14 @@ -use anyhow::{anyhow, Context, Ok, Result}; +use anyhow::{Context, Error, Ok, Result}; use oci_spec::runtime::{Capability, LinuxCapabilitiesBuilder, ProcessBuilder, Spec, SpecBuilder}; use std::collections::HashSet; use std::str::FromStr; -use test_framework::{test_result, Test, TestGroup, TestResult}; - -use crate::utils::test_inside_container; -use crate::utils::test_utils::CreateOptions; +use test_framework::{Test, TestGroup, TestResult}; fn create_spec() -> Result { - let cap_test = Capability::from_str("CAP_TEST").context("invalid capability: CAP_TEST")?; + let capability = Capability::from_str("CAP_TEST").context("invalid capability")?; let linux_capability = LinuxCapabilitiesBuilder::default() - .bounding(HashSet::from([cap_test])) - // .bounding(HashSet::from([Capability::from_str("CAP_TEST")])) + .bounding(HashSet::from([capability])) .build()?; let process = ProcessBuilder::default() @@ -33,14 +29,9 @@ fn create_spec() -> Result { } fn process_capabilities_fail_test() -> TestResult { - let spec = test_result!(create_spec()); - - let result = test_inside_container(spec, &CreateOptions::default(), &|_| Ok(())); - - match result { - TestResult::Failed(_) => TestResult::Passed, - TestResult::Passed => TestResult::Failed(anyhow!("test unexpectedly passed.")), - _ => TestResult::Failed(anyhow!("test result was unexpected.")), + match create_spec() { + Result::Ok(_) => TestResult::Failed(Error::msg("create_spec succeeded unexpectedly.")), + Err(_e) => TestResult::Passed, } }