github.com/kaixiang/packer@v0.5.2-0.20140114230416-1f5786b0d7f1/command/fix/fixer_iso_md5_test.go (about)

     1  package fix
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestFixerISOMD5_Impl(t *testing.T) {
     9  	var raw interface{}
    10  	raw = new(FixerISOMD5)
    11  	if _, ok := raw.(Fixer); !ok {
    12  		t.Fatalf("must be a Fixer")
    13  	}
    14  }
    15  
    16  func TestFixerISOMD5_Fix(t *testing.T) {
    17  	var f FixerISOMD5
    18  
    19  	input := map[string]interface{}{
    20  		"builders": []interface{}{
    21  			map[string]string{
    22  				"type":    "foo",
    23  				"iso_md5": "bar",
    24  			},
    25  		},
    26  	}
    27  
    28  	expected := map[string]interface{}{
    29  		"builders": []map[string]interface{}{
    30  			map[string]interface{}{
    31  				"type":              "foo",
    32  				"iso_checksum":      "bar",
    33  				"iso_checksum_type": "md5",
    34  			},
    35  		},
    36  	}
    37  
    38  	output, err := f.Fix(input)
    39  	if err != nil {
    40  		t.Fatalf("err: %s", err)
    41  	}
    42  
    43  	if !reflect.DeepEqual(output, expected) {
    44  		t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected)
    45  	}
    46  }