This commit is contained in:
Adrien Delorme 2019-09-20 15:28:43 +02:00
parent 792f61a4ad
commit 4fb05e5bc4
1 changed files with 6 additions and 7 deletions

View File

@ -1,11 +1,11 @@
package common package common
import ( import (
"reflect"
"testing" "testing"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/config"
) )
@ -102,6 +102,7 @@ func TestBlockDevice(t *testing.T) {
VolumeSize: aws.Int64(8), VolumeSize: aws.Int64(8),
DeleteOnTermination: aws.Bool(true), DeleteOnTermination: aws.Bool(true),
Encrypted: aws.Bool(true), Encrypted: aws.Bool(true),
KmsKeyId: aws.String("2Fa48a521f-3aff-4b34-a159-376ac5d37812"),
}, },
}, },
}, },
@ -152,15 +153,13 @@ func TestBlockDevice(t *testing.T) {
expected := []*ec2.BlockDeviceMapping{tc.Result} expected := []*ec2.BlockDeviceMapping{tc.Result}
amiResults := amiBlockDevices.BuildEC2BlockDeviceMappings() amiResults := amiBlockDevices.BuildEC2BlockDeviceMappings()
if !reflect.DeepEqual(expected, amiResults) { if diff := cmp.Diff(expected, amiResults); diff != "" {
t.Fatalf("Bad block device, \nexpected: %#v\n\ngot: %#v", t.Fatalf("Bad block device: %s", diff)
expected, amiResults)
} }
launchResults := launchBlockDevices.BuildEC2BlockDeviceMappings() launchResults := launchBlockDevices.BuildEC2BlockDeviceMappings()
if !reflect.DeepEqual(expected, launchResults) { if diff := cmp.Diff(expected, launchResults); diff != "" {
t.Fatalf("Bad block device, \nexpected: %#v\n\ngot: %#v", t.Fatalf("Bad block device: %s", diff)
expected, launchResults)
} }
} }
} }