github.com/hashicorp/packer@v1.14.3/fix/fixer_parallels_headless_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 TestFixerParallelsHeadless_Impl(t *testing.T) { 12 var _ Fixer = new(FixerParallelsHeadless) 13 } 14 15 func TestFixerParallelsHeadless_Fix(t *testing.T) { 16 cases := []struct { 17 Input map[string]interface{} 18 Expected map[string]interface{} 19 }{ 20 // No headless field 21 { 22 Input: map[string]interface{}{ 23 "type": "parallels-iso", 24 }, 25 26 Expected: map[string]interface{}{ 27 "type": "parallels-iso", 28 }, 29 }, 30 31 // Headless field 32 { 33 Input: map[string]interface{}{ 34 "type": "parallels-iso", 35 "headless": false, 36 }, 37 38 Expected: map[string]interface{}{ 39 "type": "parallels-iso", 40 }, 41 }, 42 } 43 44 for _, tc := range cases { 45 var f FixerParallelsHeadless 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 }