github.com/hashicorp/packer@v1.14.3/fix/fixer_pp_vagrant_override_test.go (about)

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