Пример #1
0
func (s *volumeSuite) TestGroupAttachmentsByVolume(c *gc.C) {
	volumeTag1 := names.NewVolumeTag("0")
	volumeTag2 := names.NewVolumeTag("0/1")
	machineTag := names.NewMachineTag("0")
	attachments := []state.VolumeAttachment{
		&mockVolumeAttachment{VolumeTag: volumeTag1, MachineTag: machineTag},
		&mockVolumeAttachment{VolumeTag: volumeTag2, MachineTag: machineTag},
		&mockVolumeAttachment{VolumeTag: volumeTag2, MachineTag: machineTag},
	}
	expected := map[string][]params.VolumeAttachment{
		volumeTag1.String(): {
			storage.ConvertStateVolumeAttachmentToParams(attachments[0])},
		volumeTag2.String(): {
			storage.ConvertStateVolumeAttachmentToParams(attachments[1]),
			storage.ConvertStateVolumeAttachmentToParams(attachments[2]),
		},
	}
	c.Assert(
		storage.GroupAttachmentsByVolume(attachments),
		jc.DeepEquals,
		expected)
}
Пример #2
0
func (s *volumeSuite) TestGroupAttachmentsByVolumeEmpty(c *gc.C) {
	c.Assert(storage.GroupAttachmentsByVolume(nil), gc.IsNil)
	c.Assert(storage.GroupAttachmentsByVolume([]state.VolumeAttachment{}), gc.IsNil)
}