2013-08-15 17:05:08 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mitchellh/goamz/ec2"
|
2013-10-16 22:29:53 -04:00
|
|
|
"reflect"
|
2013-08-15 17:05:08 -04:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBlockDevice(t *testing.T) {
|
2014-09-04 00:27:43 -04:00
|
|
|
cases := []struct {
|
|
|
|
Config *BlockDevice
|
|
|
|
Result *ec2.BlockDeviceMapping
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
Config: &BlockDevice{
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
VirtualName: "ephemeral0",
|
|
|
|
SnapshotId: "snap-1234",
|
|
|
|
VolumeType: "standard",
|
|
|
|
VolumeSize: 8,
|
|
|
|
DeleteOnTermination: true,
|
|
|
|
IOPS: 1000,
|
|
|
|
},
|
|
|
|
|
|
|
|
Result: &ec2.BlockDeviceMapping{
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
VirtualName: "ephemeral0",
|
|
|
|
SnapshotId: "snap-1234",
|
|
|
|
VolumeType: "standard",
|
|
|
|
VolumeSize: 8,
|
|
|
|
DeleteOnTermination: true,
|
|
|
|
IOPS: 1000,
|
|
|
|
},
|
2013-08-15 17:05:08 -04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2014-09-04 00:27:43 -04:00
|
|
|
for _, tc := range cases {
|
|
|
|
blockDevices := BlockDevices{
|
|
|
|
AMIMappings: []BlockDevice{*tc.Config},
|
|
|
|
LaunchMappings: []BlockDevice{*tc.Config},
|
|
|
|
}
|
2013-08-15 17:05:08 -04:00
|
|
|
|
2014-09-04 00:27:43 -04:00
|
|
|
expected := []ec2.BlockDeviceMapping{*tc.Result}
|
2013-08-15 17:05:08 -04:00
|
|
|
|
2014-09-04 00:27:43 -04:00
|
|
|
if !reflect.DeepEqual(expected, blockDevices.BuildAMIDevices()) {
|
|
|
|
t.Fatalf("bad: %#v", expected)
|
|
|
|
}
|
2013-10-16 22:29:53 -04:00
|
|
|
|
2014-09-04 00:27:43 -04:00
|
|
|
if !reflect.DeepEqual(expected, blockDevices.BuildLaunchDevices()) {
|
|
|
|
t.Fatalf("bad: %#v", expected)
|
|
|
|
}
|
2013-10-16 22:29:53 -04:00
|
|
|
}
|
2013-08-15 17:05:08 -04:00
|
|
|
}
|