File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ itertools = "0.14.0"
2828anyhow = " 1.0"
2929bytes = " 1.5"
3030clap = { version = " 4.4" , features = [" derive" ] }
31+ tempfile = " 3.20.0"
3132
3233[lib ]
3334path = " src/imageproxy.rs"
Original file line number Diff line number Diff line change @@ -773,6 +773,19 @@ mod tests {
773773 use cap_std_ext:: cap_std:: fs:: Dir ;
774774 use rustix:: fs:: { memfd_create, MemfdFlags } ;
775775
776+ /// Check if we have skopeo
777+ fn check_skopeo ( ) -> bool {
778+ static HAVE_SKOPEO : OnceLock < bool > = OnceLock :: new ( ) ;
779+ * HAVE_SKOPEO . get_or_init ( || {
780+ Command :: new ( "skopeo" )
781+ . arg ( "--help" )
782+ . stdout ( Stdio :: null ( ) )
783+ . stderr ( Stdio :: null ( ) )
784+ . status ( )
785+ . is_ok ( )
786+ } )
787+ }
788+
776789 fn validate ( c : Command , contains : & [ & str ] , not_contains : & [ & str ] ) {
777790 // Format via debug, because
778791 // https://doc.rust-lang.org/std/process/struct.Command.html#method.get_args
@@ -1011,4 +1024,21 @@ mod tests {
10111024 Err ( other) => unreachable ! ( "{other}" ) ,
10121025 }
10131026 }
1027+
1028+ #[ tokio:: test]
1029+ #[ ignore = "https://github.com/coreos/rpm-ostree/issues/5442" ]
1030+ async fn test_open_optional ( ) -> Result < ( ) > {
1031+ if !check_skopeo ( ) {
1032+ return Ok ( ( ) ) ;
1033+ }
1034+
1035+ let td = tempfile:: tempdir ( ) ?;
1036+ let td = td. path ( ) . to_str ( ) . unwrap ( ) ;
1037+ let proxy = ImageProxy :: new ( ) . await ?;
1038+ let imgpath = format ! ( "oci-archive:{td}/some-nonexistent-image.ociarchive" ) ;
1039+ let img = proxy. open_image_optional ( & imgpath) . await . unwrap ( ) ;
1040+ assert ! ( img. is_none( ) ) ;
1041+
1042+ Ok ( ( ) )
1043+ }
10141044}
You can’t perform that action at this time.
0 commit comments