mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-26 07:22:20 +00:00
rustjail: Add tests for root_grpc_to_oci
Add test coverage for root_grpc_to_oci in rustjail/src/lib.rs Fixes: #4095 Signed-off-by: Garrett Mahin <garrett.mahin@gmail.com>
This commit is contained in:
parent
698e45f403
commit
2256bcb6ab
@ -680,4 +680,61 @@ mod tests {
|
|||||||
assert_eq!(d.result, result, "{}", msg);
|
assert_eq!(d.result, result, "{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_root_grpc_to_oci() {
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct TestData {
|
||||||
|
grpcroot: grpc::Root,
|
||||||
|
result: oci::Root,
|
||||||
|
}
|
||||||
|
|
||||||
|
let tests = &[
|
||||||
|
TestData {
|
||||||
|
// Default fields
|
||||||
|
grpcroot: grpc::Root {
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
result: oci::Root {
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TestData {
|
||||||
|
// Specified fields, readonly false
|
||||||
|
grpcroot: grpc::Root {
|
||||||
|
Path: String::from("path"),
|
||||||
|
Readonly: false,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
result: oci::Root {
|
||||||
|
path: String::from("path"),
|
||||||
|
readonly: false,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TestData {
|
||||||
|
// Specified fields, readonly true
|
||||||
|
grpcroot: grpc::Root {
|
||||||
|
Path: String::from("path"),
|
||||||
|
Readonly: true,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
result: oci::Root {
|
||||||
|
path: String::from("path"),
|
||||||
|
readonly: true,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
for (i, d) in tests.iter().enumerate() {
|
||||||
|
let msg = format!("test[{}]: {:?}", i, d);
|
||||||
|
|
||||||
|
let result = root_grpc_to_oci(&d.grpcroot);
|
||||||
|
|
||||||
|
let msg = format!("{}, result: {:?}", msg, result);
|
||||||
|
|
||||||
|
assert_eq!(d.result, result, "{}", msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user