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

38 lines
694 B
Go
Raw Normal View History

2013-12-22 12:24:29 -05:00
package common
import (
"reflect"
"testing"
)
func TestVBoxManageConfigPrepare_VBoxManage(t *testing.T) {
// Test with empty
c := new(VBoxManageConfig)
errs := c.Prepare(testConfigTemplate(t))
if len(errs) > 0 {
t.Fatalf("err: %#v", errs)
}
if !reflect.DeepEqual(c.VBoxManage, [][]string{}) {
t.Fatalf("bad: %#v", c.VBoxManage)
}
// Test with a good one
c = new(VBoxManageConfig)
c.VBoxManage = [][]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"},
2013-12-22 12:24:29 -05:00
}
if !reflect.DeepEqual(c.VBoxManage, expected) {
t.Fatalf("bad: %#v", c.VBoxManage)
}
}