Commit dc74c2bb authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazon: tests

parent ad51098a
...@@ -7,8 +7,12 @@ import ( ...@@ -7,8 +7,12 @@ import (
) )
func TestBlockDevice(t *testing.T) { func TestBlockDevice(t *testing.T) {
ec2Mapping := []ec2.BlockDeviceMapping{ cases := []struct {
ec2.BlockDeviceMapping{ Config *BlockDevice
Result *ec2.BlockDeviceMapping
}{
{
Config: &BlockDevice{
DeviceName: "/dev/sdb", DeviceName: "/dev/sdb",
VirtualName: "ephemeral0", VirtualName: "ephemeral0",
SnapshotId: "snap-1234", SnapshotId: "snap-1234",
...@@ -17,9 +21,8 @@ func TestBlockDevice(t *testing.T) { ...@@ -17,9 +21,8 @@ func TestBlockDevice(t *testing.T) {
DeleteOnTermination: true, DeleteOnTermination: true,
IOPS: 1000, IOPS: 1000,
}, },
}
blockDevice := BlockDevice{ Result: &ec2.BlockDeviceMapping{
DeviceName: "/dev/sdb", DeviceName: "/dev/sdb",
VirtualName: "ephemeral0", VirtualName: "ephemeral0",
SnapshotId: "snap-1234", SnapshotId: "snap-1234",
...@@ -27,18 +30,24 @@ func TestBlockDevice(t *testing.T) { ...@@ -27,18 +30,24 @@ func TestBlockDevice(t *testing.T) {
VolumeSize: 8, VolumeSize: 8,
DeleteOnTermination: true, DeleteOnTermination: true,
IOPS: 1000, IOPS: 1000,
},
},
} }
for _, tc := range cases {
blockDevices := BlockDevices{ blockDevices := BlockDevices{
AMIMappings: []BlockDevice{blockDevice}, AMIMappings: []BlockDevice{*tc.Config},
LaunchMappings: []BlockDevice{blockDevice}, LaunchMappings: []BlockDevice{*tc.Config},
} }
if !reflect.DeepEqual(ec2Mapping, blockDevices.BuildAMIDevices()) { expected := []ec2.BlockDeviceMapping{*tc.Result}
t.Fatalf("bad: %#v", ec2Mapping)
if !reflect.DeepEqual(expected, blockDevices.BuildAMIDevices()) {
t.Fatalf("bad: %#v", expected)
} }
if !reflect.DeepEqual(ec2Mapping, blockDevices.BuildLaunchDevices()) { if !reflect.DeepEqual(expected, blockDevices.BuildLaunchDevices()) {
t.Fatalf("bad: %#v", ec2Mapping) t.Fatalf("bad: %#v", expected)
}
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment