github.com/hashicorp/packer@v1.14.3/fix/fixer_amazon_enhanced_networking_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package fix 5 6 import ( 7 "reflect" 8 "testing" 9 ) 10 11 func TestFixerAmazonEnhancedNetworking_Impl(t *testing.T) { 12 var _ Fixer = new(FixerAmazonEnhancedNetworking) 13 } 14 15 func TestFixerAmazonEnhancedNetworking(t *testing.T) { 16 cases := []struct { 17 Input map[string]interface{} 18 Expected map[string]interface{} 19 }{ 20 // Attach field == false 21 { 22 Input: map[string]interface{}{ 23 "type": "amazon-ebs", 24 "enhanced_networking": false, 25 }, 26 27 Expected: map[string]interface{}{ 28 "type": "amazon-ebs", 29 "ena_support": false, 30 }, 31 }, 32 33 // Attach field == true 34 { 35 Input: map[string]interface{}{ 36 "type": "amazon-ebs", 37 "enhanced_networking": true, 38 }, 39 40 Expected: map[string]interface{}{ 41 "type": "amazon-ebs", 42 "ena_support": true, 43 }, 44 }, 45 } 46 47 for _, tc := range cases { 48 var f FixerAmazonEnhancedNetworking 49 50 input := map[string]interface{}{ 51 "builders": []map[string]interface{}{tc.Input}, 52 } 53 54 expected := map[string]interface{}{ 55 "builders": []map[string]interface{}{tc.Expected}, 56 } 57 58 output, err := f.Fix(input) 59 if err != nil { 60 t.Fatalf("err: %s", err) 61 } 62 63 if !reflect.DeepEqual(output, expected) { 64 t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected) 65 } 66 } 67 }