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

container: Add more tests for image reference #546

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading