mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00

In #20538, I was asked to consider refactoring the new OCI pull code from within the generic machine directory. This is something I had tried when originally coding it but it became apparent that a much larger refactor to prevent circular deps was needed. Because I did not want to pollute the initial PR with that refactor, I asked for the PR to merge first. This is the refactor that needed to be done. Signed-off-by: Brent Baude <bbaude@redhat.com>
75 lines
1.1 KiB
Go
75 lines
1.1 KiB
Go
package define
|
|
|
|
import "testing"
|
|
|
|
func TestImageFormat_Kind(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
imf ImageFormat
|
|
want string
|
|
}{
|
|
{
|
|
name: "vhdx",
|
|
imf: Vhdx,
|
|
want: "vhdx",
|
|
},
|
|
{
|
|
name: "qcow2",
|
|
imf: Qcow,
|
|
want: "qcow2",
|
|
},
|
|
{
|
|
name: "raw",
|
|
imf: Raw,
|
|
want: "raw",
|
|
},
|
|
{
|
|
name: "tar",
|
|
imf: Tar,
|
|
want: "tar",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := tt.imf.Kind(); got != tt.want {
|
|
t.Errorf("Kind() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestImageFormat_KindWithCompression(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
imf ImageFormat
|
|
want string
|
|
}{
|
|
{
|
|
name: "vhdx.zip",
|
|
imf: Vhdx,
|
|
want: "vhdx.zip",
|
|
},
|
|
{
|
|
name: "qcow2",
|
|
imf: Qcow,
|
|
want: "qcow2.xz",
|
|
},
|
|
{
|
|
name: "raw.gz",
|
|
imf: Raw,
|
|
want: "raw.gz",
|
|
}, {
|
|
name: "tar.xz",
|
|
imf: Tar,
|
|
want: "tar.xz",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := tt.imf.KindWithCompression(); got != tt.want {
|
|
t.Errorf("String() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|