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