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