blueprint/output: add missing test files
These files were left out of 0272fb8815.
Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
0272fb8815
commit
c51f1833f9
7 changed files with 567 additions and 0 deletions
81
internal/blueprint/ami_output_test.go
Normal file
81
internal/blueprint/ami_output_test.go
Normal file
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
81
internal/blueprint/disk_output_test.go
Normal file
81
internal/blueprint/disk_output_test.go
Normal file
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
81
internal/blueprint/liveiso_output_test.go
Normal file
81
internal/blueprint/liveiso_output_test.go
Normal file
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
81
internal/blueprint/openstack_output_test.go
Normal file
81
internal/blueprint/openstack_output_test.go
Normal file
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
81
internal/blueprint/tar_output_test.go
Normal file
81
internal/blueprint/tar_output_test.go
Normal file
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
81
internal/blueprint/vhd_output_test.go
Normal file
81
internal/blueprint/vhd_output_test.go
Normal file
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
81
internal/blueprint/vmdk_output_test.go
Normal file
81
internal/blueprint/vmdk_output_test.go
Normal file
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue