github.com/angdraug/packer@v1.3.2/fix/fixer_hyperv_deprecations_test.go (about) 1 package fix 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestFixerHypervDeprecations_impl(t *testing.T) { 10 var _ Fixer = new(FixerHypervDeprecations) 11 } 12 13 func TestFixerHypervDeprecations_Fix(t *testing.T) { 14 cases := []struct { 15 Input map[string]interface{} 16 Expected map[string]interface{} 17 }{ 18 // No vhd_temp_path field in template - noop 19 { 20 Input: map[string]interface{}{ 21 "type": "hyperv-iso", 22 }, 23 24 Expected: map[string]interface{}{ 25 "type": "hyperv-iso", 26 }, 27 }, 28 29 // Deprecated vhd_temp_path field in template should be deleted 30 { 31 Input: map[string]interface{}{ 32 "type": "hyperv-iso", 33 "vhd_temp_path": "foopath", 34 }, 35 36 Expected: map[string]interface{}{ 37 "type": "hyperv-iso", 38 }, 39 }, 40 } 41 42 for _, tc := range cases { 43 var f FixerHypervDeprecations 44 45 input := map[string]interface{}{ 46 "builders": []map[string]interface{}{tc.Input}, 47 } 48 49 expected := map[string]interface{}{ 50 "builders": []map[string]interface{}{tc.Expected}, 51 } 52 53 output, err := f.Fix(input) 54 if err != nil { 55 t.Fatalf("err: %s", err) 56 } 57 58 assert.Equal(t, expected, output, "Should be equal") 59 } 60 }