github.phpd.cn/hashicorp/packer@v1.3.2/fix/fixer_pp_vagrant_override_test.go (about)

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