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"
28
28
anyhow = " 1.0"
29
29
bytes = " 1.5"
30
30
clap = { version = " 4.4" , features = [" derive" ] }
31
+ tempfile = " 3.20.0"
31
32
32
33
[lib ]
33
34
path = " src/imageproxy.rs"
Original file line number Diff line number Diff line change @@ -773,6 +773,19 @@ mod tests {
773
773
use cap_std_ext:: cap_std:: fs:: Dir ;
774
774
use rustix:: fs:: { memfd_create, MemfdFlags } ;
775
775
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
+
776
789
fn validate ( c : Command , contains : & [ & str ] , not_contains : & [ & str ] ) {
777
790
// Format via debug, because
778
791
// https://doc.rust-lang.org/std/process/struct.Command.html#method.get_args
@@ -1011,4 +1024,21 @@ mod tests {
1011
1024
Err ( other) => unreachable ! ( "{other}" ) ,
1012
1025
}
1013
1026
}
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
+ }
1014
1044
}
You can’t perform that action at this time.
0 commit comments