Add test that verifies disksize bug (2/2)

This commit is contained in:
Paul Meyer 2019-10-04 17:30:34 +00:00
parent 98175c06d5
commit b5c0742951
1 changed files with 45 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package chroot
import (
"reflect"
"regexp"
"testing"
@ -26,3 +27,47 @@ func TestBuilder_Prepare_DiskAsInput(t *testing.T) {
}
}
}
func TestBuilder_Prepare(t *testing.T) {
type config map[string]interface{}
tests := []struct {
name string
config config
want []string
validate func(Config)
wantErr bool
}{
{
name: "HappyPath",
config: config{
"client_id": "123",
"client_secret": "456",
"subscription_id": "789",
"resource_group": "rgname",
"image_resource_id": "/subscriptions/789/resourceGroups/otherrgname/providers/Microsoft.Compute/images/MyDebianOSImage-{{timestamp}}",
"source": "credativ:Debian:9:latest",
},
wantErr: false,
validate: func(c Config){
if(c.OSDiskSizeGB!=0){
t.Fatalf("Expected OSDiskSizeGB to be 0, was %+v", c.OSDiskSizeGB)
}
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := &Builder{}
got, err := b.Prepare(tt.config)
if (err != nil) != tt.wantErr {
t.Errorf("Builder.Prepare() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Builder.Prepare() = %v, want %v", got, tt.want)
}
})
}
}