github.com/mitchellh/packer@v1.3.2/builder/virtualbox/common/vboxmanage_post_config_test.go (about)

     1  package common
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestVBoxManagePostConfigPrepare_VBoxManage(t *testing.T) {
     9  	// Test with empty
    10  	c := new(VBoxManagePostConfig)
    11  	errs := c.Prepare(testConfigTemplate(t))
    12  	if len(errs) > 0 {
    13  		t.Fatalf("err: %#v", errs)
    14  	}
    15  
    16  	if !reflect.DeepEqual(c.VBoxManagePost, [][]string{}) {
    17  		t.Fatalf("bad: %#v", c.VBoxManagePost)
    18  	}
    19  
    20  	// Test with a good one
    21  	c = new(VBoxManagePostConfig)
    22  	c.VBoxManagePost = [][]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  		{"foo", "bar", "baz"},
    32  	}
    33  
    34  	if !reflect.DeepEqual(c.VBoxManagePost, expected) {
    35  		t.Fatalf("bad: %#v", c.VBoxManagePost)
    36  	}
    37  }