github.com/hashicorp/packer@v1.14.3/fix/fixer_iso_md5_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 TestFixerISOMD5_Impl(t *testing.T) { 12 var raw interface{} 13 raw = new(FixerISOMD5) 14 if _, ok := raw.(Fixer); !ok { 15 t.Fatalf("must be a Fixer") 16 } 17 } 18 19 func TestFixerISOMD5_Fix(t *testing.T) { 20 var f FixerISOMD5 21 22 input := map[string]interface{}{ 23 "builders": []interface{}{ 24 map[string]string{ 25 "type": "foo", 26 "iso_md5": "bar", 27 }, 28 }, 29 } 30 31 expected := map[string]interface{}{ 32 "builders": []map[string]interface{}{ 33 { 34 "type": "foo", 35 "iso_checksum": "bar", 36 "iso_checksum_type": "md5", 37 }, 38 }, 39 } 40 41 output, err := f.Fix(input) 42 if err != nil { 43 t.Fatalf("err: %s", err) 44 } 45 46 if !reflect.DeepEqual(output, expected) { 47 t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected) 48 } 49 }