Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #546 from cgwalters/more-imgref-tests
Browse files Browse the repository at this point in the history
container: Add more tests for image reference
  • Loading branch information
cgwalters authored Sep 26, 2023
2 parents 88b5fc7 + d19f948 commit bf7137c
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions lib/src/container/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,39 @@ mod tests {
panic!("Should fail to parse: {}", v)
}
}
let ir: ImageReference = "oci:somedir".try_into().unwrap();
assert_eq!(ir.transport, Transport::OciDir);
assert_eq!(ir.name, "somedir");

let ir: ImageReference = "dir:/some/dir/blah".try_into().unwrap();
assert_eq!(ir.transport, Transport::Dir);
assert_eq!(ir.name, "/some/dir/blah");
struct Case {
s: &'static str,
transport: Transport,
name: &'static str,
}
for case in [
Case {
s: "oci:somedir",
transport: Transport::OciDir,
name: "somedir",
},
Case {
s: "dir:/some/dir/blah",
transport: Transport::Dir,
name: "/some/dir/blah",
},
Case {
s: "oci-archive:/path/to/foo.ociarchive",
transport: Transport::OciArchive,
name: "/path/to/foo.ociarchive",
},
Case {
s: "containers-storage:localhost/someimage:blah",
transport: Transport::ContainerStorage,
name: "localhost/someimage:blah",
},
] {
let ir: ImageReference = case.s.try_into().unwrap();
assert_eq!(ir.transport, case.transport);
assert_eq!(ir.name, case.name);
let reserialized = ir.to_string();
assert_eq!(case.s, reserialized.as_str());
}
}

#[test]
Expand Down

0 comments on commit bf7137c

Please sign in to comment.