github.com/aspring/packer@v0.8.1-0.20150629211158-9db281ac0f89/fix/fixer_pp_vagrant_override_test.go (about)

     1  package fix
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestFixerVagrantPPOverride_Impl(t *testing.T) {
     9  	var _ Fixer = new(FixerVagrantPPOverride)
    10  }
    11  
    12  func TestFixerVagrantPPOverride_Fix(t *testing.T) {
    13  	var f FixerVagrantPPOverride
    14  
    15  	input := map[string]interface{}{
    16  		"post-processors": []interface{}{
    17  			"foo",
    18  
    19  			map[string]interface{}{
    20  				"type": "vagrant",
    21  				"aws": map[string]interface{}{
    22  					"foo": "bar",
    23  				},
    24  			},
    25  
    26  			map[string]interface{}{
    27  				"type": "vsphere",
    28  			},
    29  
    30  			[]interface{}{
    31  				map[string]interface{}{
    32  					"type": "vagrant",
    33  					"vmware": map[string]interface{}{
    34  						"foo": "bar",
    35  					},
    36  				},
    37  			},
    38  		},
    39  	}
    40  
    41  	expected := map[string]interface{}{
    42  		"post-processors": []interface{}{
    43  			"foo",
    44  
    45  			map[string]interface{}{
    46  				"type": "vagrant",
    47  				"override": map[string]interface{}{
    48  					"aws": map[string]interface{}{
    49  						"foo": "bar",
    50  					},
    51  				},
    52  			},
    53  
    54  			map[string]interface{}{
    55  				"type": "vsphere",
    56  			},
    57  
    58  			[]interface{}{
    59  				map[string]interface{}{
    60  					"type": "vagrant",
    61  					"override": map[string]interface{}{
    62  						"vmware": map[string]interface{}{
    63  							"foo": "bar",
    64  						},
    65  					},
    66  				},
    67  			},
    68  		},
    69  	}
    70  
    71  	output, err := f.Fix(input)
    72  	if err != nil {
    73  		t.Fatalf("err: %s", err)
    74  	}
    75  
    76  	if !reflect.DeepEqual(output, expected) {
    77  		t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected)
    78  	}
    79  }