Commit dc74c2bb authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazon: tests

parent ad51098a
...@@ -7,38 +7,47 @@ import ( ...@@ -7,38 +7,47 @@ import (
) )
func TestBlockDevice(t *testing.T) { func TestBlockDevice(t *testing.T) {
ec2Mapping := []ec2.BlockDeviceMapping{ cases := []struct {
ec2.BlockDeviceMapping{ Config *BlockDevice
DeviceName: "/dev/sdb", Result *ec2.BlockDeviceMapping
VirtualName: "ephemeral0", }{
SnapshotId: "snap-1234", {
VolumeType: "standard", Config: &BlockDevice{
VolumeSize: 8, DeviceName: "/dev/sdb",
DeleteOnTermination: true, VirtualName: "ephemeral0",
IOPS: 1000, 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,
},
}, },
} }
blockDevice := BlockDevice{ for _, tc := range cases {
DeviceName: "/dev/sdb", blockDevices := BlockDevices{
VirtualName: "ephemeral0", AMIMappings: []BlockDevice{*tc.Config},
SnapshotId: "snap-1234", LaunchMappings: []BlockDevice{*tc.Config},
VolumeType: "standard", }
VolumeSize: 8,
DeleteOnTermination: true,
IOPS: 1000,
}
blockDevices := BlockDevices{ expected := []ec2.BlockDeviceMapping{*tc.Result}
AMIMappings: []BlockDevice{blockDevice},
LaunchMappings: []BlockDevice{blockDevice},
}
if !reflect.DeepEqual(ec2Mapping, blockDevices.BuildAMIDevices()) { if !reflect.DeepEqual(expected, blockDevices.BuildAMIDevices()) {
t.Fatalf("bad: %#v", ec2Mapping) 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