debian-forge-composer/internal/blueprint/disk_output_test.go
Tom Gundersen c51f1833f9 blueprint/output: add missing test files
These files were left out of 0272fb8815.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-21 23:17:49 +02:00

81 lines
1.5 KiB
Go

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)
}
})
}
}