github.com/kaixiang/packer@v0.5.2-0.20140114230416-1f5786b0d7f1/command/fix/fixer_virtualbox_rename_test.go (about)

     1  package fix
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestFixerVirtualBoxRename_impl(t *testing.T) {
     9  	var _ Fixer = new(FixerVirtualBoxRename)
    10  }
    11  
    12  func TestFixerVirtualBoxRename_Fix(t *testing.T) {
    13  	cases := []struct {
    14  		Input    map[string]interface{}
    15  		Expected map[string]interface{}
    16  	}{
    17  		{
    18  			Input: map[string]interface{}{
    19  				"type": "virtualbox",
    20  			},
    21  
    22  			Expected: map[string]interface{}{
    23  				"type": "virtualbox-iso",
    24  			},
    25  		},
    26  	}
    27  
    28  	for _, tc := range cases {
    29  		var f FixerVirtualBoxRename
    30  
    31  		input := map[string]interface{}{
    32  			"builders": []map[string]interface{}{tc.Input},
    33  		}
    34  
    35  		expected := map[string]interface{}{
    36  			"builders": []map[string]interface{}{tc.Expected},
    37  		}
    38  
    39  		output, err := f.Fix(input)
    40  		if err != nil {
    41  			t.Fatalf("err: %s", err)
    42  		}
    43  
    44  		if !reflect.DeepEqual(output, expected) {
    45  			t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected)
    46  		}
    47  	}
    48  }