github.com/containers/podman/v4@v4.9.4/pkg/machine/define/image_format_test.go (about)

     1  package define
     2  
     3  import "testing"
     4  
     5  func TestImageFormat_Kind(t *testing.T) {
     6  	tests := []struct {
     7  		name string
     8  		imf  ImageFormat
     9  		want string
    10  	}{
    11  		{
    12  			name: "vhdx",
    13  			imf:  Vhdx,
    14  			want: "vhdx",
    15  		},
    16  		{
    17  			name: "qcow2",
    18  			imf:  Qcow,
    19  			want: "qcow2",
    20  		},
    21  		{
    22  			name: "raw",
    23  			imf:  Raw,
    24  			want: "raw",
    25  		},
    26  		{
    27  			name: "tar",
    28  			imf:  Tar,
    29  			want: "tar",
    30  		},
    31  	}
    32  	for _, tt := range tests {
    33  		t.Run(tt.name, func(t *testing.T) {
    34  			if got := tt.imf.Kind(); got != tt.want {
    35  				t.Errorf("Kind() = %v, want %v", got, tt.want)
    36  			}
    37  		})
    38  	}
    39  }
    40  
    41  func TestImageFormat_KindWithCompression(t *testing.T) {
    42  	tests := []struct {
    43  		name string
    44  		imf  ImageFormat
    45  		want string
    46  	}{
    47  		{
    48  			name: "vhdx.zip",
    49  			imf:  Vhdx,
    50  			want: "vhdx.zip",
    51  		},
    52  		{
    53  			name: "qcow2",
    54  			imf:  Qcow,
    55  			want: "qcow2.xz",
    56  		},
    57  		{
    58  			name: "raw.gz",
    59  			imf:  Raw,
    60  			want: "raw.gz",
    61  		}, {
    62  			name: "tar.xz",
    63  			imf:  Tar,
    64  			want: "tar.xz",
    65  		},
    66  	}
    67  	for _, tt := range tests {
    68  		t.Run(tt.name, func(t *testing.T) {
    69  			if got := tt.imf.KindWithCompression(); got != tt.want {
    70  				t.Errorf("String() = %v, want %v", got, tt.want)
    71  			}
    72  		})
    73  	}
    74  }