github.com/hashicorp/packer@v1.14.3/fix/fixer_hyperv_vmxc_typo_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 TestFixerHypervVmxcTypo_impl(t *testing.T) { 13 var _ Fixer = new(FixerHypervVmxcTypo) 14 } 15 16 func TestFixerHypervVmxcTypo_Fix(t *testing.T) { 17 cases := []struct { 18 Input map[string]interface{} 19 Expected map[string]interface{} 20 }{ 21 // No "clone_from_vmxc_path" in template - noop 22 { 23 Input: map[string]interface{}{ 24 "type": "hyperv-vmcx", 25 "temp_path": "C:/some/temp/path", 26 }, 27 28 Expected: map[string]interface{}{ 29 "type": "hyperv-vmcx", 30 "temp_path": "C:/some/temp/path", 31 }, 32 }, 33 34 // "clone_from_vmxc_path" should be replaced with 35 // "clone_from_vmcx_path" in template 36 { 37 Input: map[string]interface{}{ 38 "type": "hyperv-vmcx", 39 "clone_from_vmxc_path": "C:/some/vmcx/path", 40 }, 41 42 Expected: map[string]interface{}{ 43 "type": "hyperv-vmcx", 44 "clone_from_vmcx_path": "C:/some/vmcx/path", 45 }, 46 }, 47 } 48 49 for _, tc := range cases { 50 var f FixerHypervVmxcTypo 51 52 input := map[string]interface{}{ 53 "builders": []map[string]interface{}{tc.Input}, 54 } 55 56 expected := map[string]interface{}{ 57 "builders": []map[string]interface{}{tc.Expected}, 58 } 59 60 output, err := f.Fix(input) 61 if err != nil { 62 t.Fatalf("err: %s", err) 63 } 64 65 assert.Equal(t, expected, output, "Should be equal") 66 } 67 }