github.com/sneal/packer@v0.5.2/builder/virtualbox/common/vboxmanage_config_test.go (about)

     1  package common
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestVBoxManageConfigPrepare_VBoxManage(t *testing.T) {
     9  	// Test with empty
    10  	c := new(VBoxManageConfig)
    11  	errs := c.Prepare(testConfigTemplate(t))
    12  	if len(errs) > 0 {
    13  		t.Fatalf("err: %#v", errs)
    14  	}
    15  
    16  	if !reflect.DeepEqual(c.VBoxManage, [][]string{}) {
    17  		t.Fatalf("bad: %#v", c.VBoxManage)
    18  	}
    19  
    20  	// Test with a good one
    21  	c = new(VBoxManageConfig)
    22  	c.VBoxManage = [][]string{
    23  		{"foo", "bar", "baz"},
    24  	}
    25  	errs = c.Prepare(testConfigTemplate(t))
    26  	if len(errs) > 0 {
    27  		t.Fatalf("err: %#v", errs)
    28  	}
    29  
    30  	expected := [][]string{
    31  		[]string{"foo", "bar", "baz"},
    32  	}
    33  
    34  	if !reflect.DeepEqual(c.VBoxManage, expected) {
    35  		t.Fatalf("bad: %#v", c.VBoxManage)
    36  	}
    37  }