packer-cn/builder/virtualbox/common/vboxmanage_post_config_test.go

38 lines
726 B
Go
Raw Normal View History

package common
import (
"reflect"
"testing"
)
func TestVBoxManagePostConfigPrepare_VBoxManage(t *testing.T) {
// Test with empty
c := new(VBoxManagePostConfig)
errs := c.Prepare(testConfigTemplate(t))
if len(errs) > 0 {
t.Fatalf("err: %#v", errs)
}
if !reflect.DeepEqual(c.VBoxManagePost, [][]string{}) {
t.Fatalf("bad: %#v", c.VBoxManagePost)
}
// Test with a good one
c = new(VBoxManagePostConfig)
c.VBoxManagePost = [][]string{
{"foo", "bar", "baz"},
}
errs = c.Prepare(testConfigTemplate(t))
if len(errs) > 0 {
t.Fatalf("err: %#v", errs)
}
expected := [][]string{
2016-11-01 17:08:04 -04:00
{"foo", "bar", "baz"},
}
if !reflect.DeepEqual(c.VBoxManagePost, expected) {
t.Fatalf("bad: %#v", c.VBoxManagePost)
}
}