Skip to content

Commit

Permalink
image: add minimal test for vmdk
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 authored and cgwalters committed Mar 8, 2024
1 parent 9822457 commit 6b51d80
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions pkg/image/bootc_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,24 @@ func makeFakeDigest(t *testing.T) string {
}

type bootcDiskImageTestOpts struct {
BIOS bool
ImageFormat platform.ImageFormat
BIOS bool
}

func makeFakePlatform(opts *bootcDiskImageTestOpts) platform.Platform {
return &platform.X86{
BasePlatform: platform.BasePlatform{
ImageFormat: platform.FORMAT_QCOW2,
ImageFormat: opts.ImageFormat,
},
BIOS: opts.BIOS,
}
}

func makeBootcDiskImageOsbuildManifest(t *testing.T, opts *bootcDiskImageTestOpts) manifest.OSBuildManifest {
if opts == nil {
opts = &bootcDiskImageTestOpts{}
opts = &bootcDiskImageTestOpts{
ImageFormat: platform.FORMAT_QCOW2,
}
}

containerSource := container.SourceSpec{
Expand Down Expand Up @@ -116,6 +119,14 @@ func TestBootcDiskImageInstantiateNoBuildpipelineForQcow2(t *testing.T) {
assert.Equal(t, qcowPipeline["build"], nil)
}

func TestBootcDiskImageInstantiateVmdk(t *testing.T) {
opts := &bootcDiskImageTestOpts{ImageFormat: platform.FORMAT_VMDK}
osbuildManifest := makeBootcDiskImageOsbuildManifest(t, opts)

pipeline := findPipelineFromOsbuildManifest(t, osbuildManifest, "vmdk")
require.NotNil(t, pipeline)
}

func TestBootcDiskImageUsesBootupd(t *testing.T) {
osbuildManifest := makeBootcDiskImageOsbuildManifest(t, nil)

Expand All @@ -134,7 +145,7 @@ func TestBootcDiskImageUsesBootupd(t *testing.T) {

func TestBootcDiskImageBootupdBiosSupport(t *testing.T) {
for _, withBios := range []bool{false, true} {
osbuildManifest := makeBootcDiskImageOsbuildManifest(t, &bootcDiskImageTestOpts{BIOS: withBios})
osbuildManifest := makeBootcDiskImageOsbuildManifest(t, &bootcDiskImageTestOpts{BIOS: withBios, ImageFormat: platform.FORMAT_QCOW2})

imagePipeline := findPipelineFromOsbuildManifest(t, osbuildManifest, "image")
require.NotNil(t, imagePipeline)
Expand Down

0 comments on commit 6b51d80

Please sign in to comment.