github.com/rsyabuta/packer@v1.1.4-0.20180119234903-5ef0c2280f0b/fix/fixer_parallels_headless_test.go (about)

     1  package fix
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestFixerParallelsHeadless_Impl(t *testing.T) {
     9  	var _ Fixer = new(FixerParallelsHeadless)
    10  }
    11  
    12  func TestFixerParallelsHeadless_Fix(t *testing.T) {
    13  	cases := []struct {
    14  		Input    map[string]interface{}
    15  		Expected map[string]interface{}
    16  	}{
    17  		// No headless field
    18  		{
    19  			Input: map[string]interface{}{
    20  				"type": "parallels-iso",
    21  			},
    22  
    23  			Expected: map[string]interface{}{
    24  				"type": "parallels-iso",
    25  			},
    26  		},
    27  
    28  		// Headless field
    29  		{
    30  			Input: map[string]interface{}{
    31  				"type":     "parallels-iso",
    32  				"headless": false,
    33  			},
    34  
    35  			Expected: map[string]interface{}{
    36  				"type": "parallels-iso",
    37  			},
    38  		},
    39  	}
    40  
    41  	for _, tc := range cases {
    42  		var f FixerParallelsHeadless
    43  
    44  		input := map[string]interface{}{
    45  			"builders": []map[string]interface{}{tc.Input},
    46  		}
    47  
    48  		expected := map[string]interface{}{
    49  			"builders": []map[string]interface{}{tc.Expected},
    50  		}
    51  
    52  		output, err := f.Fix(input)
    53  		if err != nil {
    54  			t.Fatalf("err: %s", err)
    55  		}
    56  
    57  		if !reflect.DeepEqual(output, expected) {
    58  			t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected)
    59  		}
    60  	}
    61  }