diff --git a/internal/blueprint/ami_output_test.go b/internal/blueprint/ami_output_test.go new file mode 100644 index 000000000..aadcb08cf --- /dev/null +++ b/internal/blueprint/ami_output_test.go @@ -0,0 +1,81 @@ +package blueprint + +import ( + "encoding/json" + "io/ioutil" + "reflect" + "testing" + + "github.com/osbuild/osbuild-composer/internal/pipeline" +) + +func Test_amiOutput_translate(t *testing.T) { + type args struct { + b *Blueprint + } + tests := []struct { + name string + t *amiOutput + args args + want string + }{ + { + name: "empty-blueprint", + t: &amiOutput{}, + args: args{&Blueprint{}}, + want: "pipelines/ami_empty_blueprint.json", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + file, _ := ioutil.ReadFile(tt.want) + var want pipeline.Pipeline + json.Unmarshal([]byte(file), &want) + if got := tt.t.translate(tt.args.b); !reflect.DeepEqual(got, &want) { + t.Errorf("amiOutput.translate() = %v, want %v", got, &want) + } + }) + } +} + +func Test_amiOutput_getName(t *testing.T) { + tests := []struct { + name string + t *amiOutput + want string + }{ + { + name: "basic", + t: &amiOutput{}, + want: "image.ami", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getName(); got != tt.want { + t.Errorf("amiOutput.getName() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_amiOutput_getMime(t *testing.T) { + tests := []struct { + name string + t *amiOutput + want string + }{ + { + name: "basic", + t: &amiOutput{}, + want: "application/x-qemu-disk", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getMime(); got != tt.want { + t.Errorf("amiOutput.getMime() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/internal/blueprint/disk_output_test.go b/internal/blueprint/disk_output_test.go new file mode 100644 index 000000000..e4eca70ac --- /dev/null +++ b/internal/blueprint/disk_output_test.go @@ -0,0 +1,81 @@ +package blueprint + +import ( + "encoding/json" + "io/ioutil" + "reflect" + "testing" + + "github.com/osbuild/osbuild-composer/internal/pipeline" +) + +func Test_diskOutput_translate(t *testing.T) { + type args struct { + b *Blueprint + } + tests := []struct { + name string + t *diskOutput + args args + want string + }{ + { + name: "empty-blueprint", + t: &diskOutput{}, + args: args{&Blueprint{}}, + want: "pipelines/disk_empty_blueprint.json", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + file, _ := ioutil.ReadFile(tt.want) + var want pipeline.Pipeline + json.Unmarshal([]byte(file), &want) + if got := tt.t.translate(tt.args.b); !reflect.DeepEqual(got, &want) { + t.Errorf("diskOutput.translate() = %v, want %v", got, &want) + } + }) + } +} + +func Test_diskOutput_getName(t *testing.T) { + tests := []struct { + name string + t *diskOutput + want string + }{ + { + name: "basic", + t: &diskOutput{}, + want: "image.img", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getName(); got != tt.want { + t.Errorf("diskOutput.getName() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_diskOutput_getMime(t *testing.T) { + tests := []struct { + name string + t *diskOutput + want string + }{ + { + name: "basic", + t: &diskOutput{}, + want: "application/octet-stream", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getMime(); got != tt.want { + t.Errorf("diskOutput.getMime() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/internal/blueprint/liveiso_output_test.go b/internal/blueprint/liveiso_output_test.go new file mode 100644 index 000000000..30ab8b205 --- /dev/null +++ b/internal/blueprint/liveiso_output_test.go @@ -0,0 +1,81 @@ +package blueprint + +import ( + "encoding/json" + "io/ioutil" + "reflect" + "testing" + + "github.com/osbuild/osbuild-composer/internal/pipeline" +) + +func Test_liveIsoOutput_translate(t *testing.T) { + type args struct { + b *Blueprint + } + tests := []struct { + name string + t *liveIsoOutput + args args + want string + }{ + { + name: "empty-blueprint", + t: &liveIsoOutput{}, + args: args{&Blueprint{}}, + want: "pipelines/liveiso_empty_blueprint.json", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + file, _ := ioutil.ReadFile(tt.want) + var want pipeline.Pipeline + json.Unmarshal([]byte(file), &want) + if got := tt.t.translate(tt.args.b); !reflect.DeepEqual(got, &want) { + t.Errorf("liveIsoOutput.translate() = %v, want %v", got, &want) + } + }) + } +} + +func Test_liveIsoOutput_getName(t *testing.T) { + tests := []struct { + name string + t *liveIsoOutput + want string + }{ + { + name: "basic", + t: &liveIsoOutput{}, + want: "image.iso", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getName(); got != tt.want { + t.Errorf("liveIsoOutput.getName() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_liveIsoOutput_getMime(t *testing.T) { + tests := []struct { + name string + t *liveIsoOutput + want string + }{ + { + name: "basic", + t: &liveIsoOutput{}, + want: "application/x-iso9660-image", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getMime(); got != tt.want { + t.Errorf("liveIsoOutput.getMime() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/internal/blueprint/openstack_output_test.go b/internal/blueprint/openstack_output_test.go new file mode 100644 index 000000000..23f1fadbb --- /dev/null +++ b/internal/blueprint/openstack_output_test.go @@ -0,0 +1,81 @@ +package blueprint + +import ( + "encoding/json" + "io/ioutil" + "reflect" + "testing" + + "github.com/osbuild/osbuild-composer/internal/pipeline" +) + +func Test_openstackOutput_translate(t *testing.T) { + type args struct { + b *Blueprint + } + tests := []struct { + name string + t *openstackOutput + args args + want string + }{ + { + name: "empty-blueprint", + t: &openstackOutput{}, + args: args{&Blueprint{}}, + want: "pipelines/openstack_empty_blueprint.json", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + file, _ := ioutil.ReadFile(tt.want) + var want pipeline.Pipeline + json.Unmarshal([]byte(file), &want) + if got := tt.t.translate(tt.args.b); !reflect.DeepEqual(got, &want) { + t.Errorf("openstackOutput.translate() = %v, want %v", got, &want) + } + }) + } +} + +func Test_openstackOutput_getName(t *testing.T) { + tests := []struct { + name string + t *openstackOutput + want string + }{ + { + name: "basic", + t: &openstackOutput{}, + want: "image.qcow2", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getName(); got != tt.want { + t.Errorf("openstackOutput.getName() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_openstackOutput_getMime(t *testing.T) { + tests := []struct { + name string + t *openstackOutput + want string + }{ + { + name: "basic", + t: &openstackOutput{}, + want: "application/x-qemu-disk", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getMime(); got != tt.want { + t.Errorf("openstackOutput.getMime() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/internal/blueprint/tar_output_test.go b/internal/blueprint/tar_output_test.go new file mode 100644 index 000000000..66bea2bcb --- /dev/null +++ b/internal/blueprint/tar_output_test.go @@ -0,0 +1,81 @@ +package blueprint + +import ( + "encoding/json" + "io/ioutil" + "reflect" + "testing" + + "github.com/osbuild/osbuild-composer/internal/pipeline" +) + +func Test_tarOutput_translate(t *testing.T) { + type args struct { + b *Blueprint + } + tests := []struct { + name string + t *tarOutput + args args + want string + }{ + { + name: "empty-blueprint", + t: &tarOutput{}, + args: args{&Blueprint{}}, + want: "pipelines/tar_empty_blueprint.json", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + file, _ := ioutil.ReadFile(tt.want) + var want pipeline.Pipeline + json.Unmarshal([]byte(file), &want) + if got := tt.t.translate(tt.args.b); !reflect.DeepEqual(got, &want) { + t.Errorf("tarOutput.translate() = %v, want %v", got, &want) + } + }) + } +} + +func Test_tarOutput_getName(t *testing.T) { + tests := []struct { + name string + t *tarOutput + want string + }{ + { + name: "basic", + t: &tarOutput{}, + want: "image.tar", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getName(); got != tt.want { + t.Errorf("tarOutput.getName() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_tarOutput_getMime(t *testing.T) { + tests := []struct { + name string + t *tarOutput + want string + }{ + { + name: "basic", + t: &tarOutput{}, + want: "application/x-tar", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getMime(); got != tt.want { + t.Errorf("tarOutput.getMime() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/internal/blueprint/vhd_output_test.go b/internal/blueprint/vhd_output_test.go new file mode 100644 index 000000000..5d167d91c --- /dev/null +++ b/internal/blueprint/vhd_output_test.go @@ -0,0 +1,81 @@ +package blueprint + +import ( + "encoding/json" + "io/ioutil" + "reflect" + "testing" + + "github.com/osbuild/osbuild-composer/internal/pipeline" +) + +func Test_vhdOutput_translate(t *testing.T) { + type args struct { + b *Blueprint + } + tests := []struct { + name string + t *vhdOutput + args args + want string + }{ + { + name: "empty-blueprint", + t: &vhdOutput{}, + args: args{&Blueprint{}}, + want: "pipelines/vhd_empty_blueprint.json", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + file, _ := ioutil.ReadFile(tt.want) + var want pipeline.Pipeline + json.Unmarshal([]byte(file), &want) + if got := tt.t.translate(tt.args.b); !reflect.DeepEqual(got, &want) { + t.Errorf("vhdOutput.translate() = %v, want %v", got, &want) + } + }) + } +} + +func Test_vhdOutput_getName(t *testing.T) { + tests := []struct { + name string + t *vhdOutput + want string + }{ + { + name: "basic", + t: &vhdOutput{}, + want: "image.vhd", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getName(); got != tt.want { + t.Errorf("vhdOutput.getName() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_vhdOutput_getMime(t *testing.T) { + tests := []struct { + name string + t *vhdOutput + want string + }{ + { + name: "basic", + t: &vhdOutput{}, + want: "application/x-vhd", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getMime(); got != tt.want { + t.Errorf("vhdOutput.getMime() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/internal/blueprint/vmdk_output_test.go b/internal/blueprint/vmdk_output_test.go new file mode 100644 index 000000000..07fd2f05f --- /dev/null +++ b/internal/blueprint/vmdk_output_test.go @@ -0,0 +1,81 @@ +package blueprint + +import ( + "encoding/json" + "io/ioutil" + "reflect" + "testing" + + "github.com/osbuild/osbuild-composer/internal/pipeline" +) + +func Test_vmdkOutput_translate(t *testing.T) { + type args struct { + b *Blueprint + } + tests := []struct { + name string + t *vmdkOutput + args args + want string + }{ + { + name: "empty-blueprint", + t: &vmdkOutput{}, + args: args{&Blueprint{}}, + want: "pipelines/vmdk_empty_blueprint.json", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + file, _ := ioutil.ReadFile(tt.want) + var want pipeline.Pipeline + json.Unmarshal([]byte(file), &want) + if got := tt.t.translate(tt.args.b); !reflect.DeepEqual(got, &want) { + t.Errorf("vmdkOutput.translate() = %v, want %v", got, &want) + } + }) + } +} + +func Test_vmdkOutput_getName(t *testing.T) { + tests := []struct { + name string + t *vmdkOutput + want string + }{ + { + name: "basic", + t: &vmdkOutput{}, + want: "image.vmdk", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getName(); got != tt.want { + t.Errorf("vmdkOutput.getName() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_vmdkOutput_getMime(t *testing.T) { + tests := []struct { + name string + t *vmdkOutput + want string + }{ + { + name: "basic", + t: &vmdkOutput{}, + want: "application/x-vmdk", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.t.getMime(); got != tt.want { + t.Errorf("vmdkOutput.getMime() = %v, want %v", got, tt.want) + } + }) + } +}