builder/amazon: tests

This commit is contained in:
Mitchell Hashimoto 2014-09-03 21:27:43 -07:00
parent ad51098a3e
commit dc74c2bbdd
1 changed files with 36 additions and 27 deletions

View File

@ -7,8 +7,12 @@ import (
)
func TestBlockDevice(t *testing.T) {
ec2Mapping := []ec2.BlockDeviceMapping{
ec2.BlockDeviceMapping{
cases := []struct {
Config *BlockDevice
Result *ec2.BlockDeviceMapping
}{
{
Config: &BlockDevice{
DeviceName: "/dev/sdb",
VirtualName: "ephemeral0",
SnapshotId: "snap-1234",
@ -17,9 +21,8 @@ func TestBlockDevice(t *testing.T) {
DeleteOnTermination: true,
IOPS: 1000,
},
}
blockDevice := BlockDevice{
Result: &ec2.BlockDeviceMapping{
DeviceName: "/dev/sdb",
VirtualName: "ephemeral0",
SnapshotId: "snap-1234",
@ -27,18 +30,24 @@ func TestBlockDevice(t *testing.T) {
VolumeSize: 8,
DeleteOnTermination: true,
IOPS: 1000,
},
},
}
for _, tc := range cases {
blockDevices := BlockDevices{
AMIMappings: []BlockDevice{blockDevice},
LaunchMappings: []BlockDevice{blockDevice},
AMIMappings: []BlockDevice{*tc.Config},
LaunchMappings: []BlockDevice{*tc.Config},
}
if !reflect.DeepEqual(ec2Mapping, blockDevices.BuildAMIDevices()) {
t.Fatalf("bad: %#v", ec2Mapping)
expected := []ec2.BlockDeviceMapping{*tc.Result}
if !reflect.DeepEqual(expected, blockDevices.BuildAMIDevices()) {
t.Fatalf("bad: %#v", expected)
}
if !reflect.DeepEqual(ec2Mapping, blockDevices.BuildLaunchDevices()) {
t.Fatalf("bad: %#v", ec2Mapping)
if !reflect.DeepEqual(expected, blockDevices.BuildLaunchDevices()) {
t.Fatalf("bad: %#v", expected)
}
}
}