Ejemplo n.º 1
0
func (s *volumeSuite) TestVolumeAttachments(c *gc.C) {
	expectedVolume, err := storage.ConvertStateVolumeToParams(s.api, s.volume)
	c.Assert(err, jc.ErrorIsNil)
	expected := params.VolumeItem{
		Volume: expectedVolume,
		Attachments: storage.ConvertStateVolumeAttachmentsToParams(
			[]state.VolumeAttachment{s.volumeAttachment},
		),
	}

	found := storage.VolumeAttachments(s.api, []state.Volume{s.volume})
	c.Assert(found, gc.HasLen, 1)
	c.Assert(found[0], gc.DeepEquals, expected)
}
Ejemplo n.º 2
0
func (s *volumeSuite) TestListVolumesEmptyFilter(c *gc.C) {
	expectedVolume, err := storage.ConvertStateVolumeToParams(s.api, s.volume)
	c.Assert(err, jc.ErrorIsNil)
	expected := params.VolumeItem{
		Volume: expectedVolume,
		Attachments: storage.ConvertStateVolumeAttachmentsToParams(
			[]state.VolumeAttachment{s.volumeAttachment},
		),
	}
	found, err := s.api.ListVolumes(params.VolumeFilter{})
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(found.Results, gc.HasLen, 1)
	c.Assert(found.Results[0], gc.DeepEquals, expected)
}
Ejemplo n.º 3
0
func (s *volumeSuite) TestFilterVolumes(c *gc.C) {
	filter := params.VolumeFilter{
		Machines: []string{s.machineTag.String()}}

	expectedVolume, err := storage.ConvertStateVolumeToParams(s.api, s.volume)
	c.Assert(err, jc.ErrorIsNil)
	expected := params.VolumeItem{
		Volume: expectedVolume,
		Attachments: storage.ConvertStateVolumeAttachmentsToParams(
			[]state.VolumeAttachment{s.volumeAttachment},
		),
	}
	found := storage.FilterVolumes(s.api, filter)
	c.Assert(found, gc.HasLen, 1)
	c.Assert(found[0], gc.DeepEquals, expected)
}
Ejemplo n.º 4
0
func (s *volumeSuite) TestGetVolumeItems(c *gc.C) {
	machineTag := names.NewMachineTag("0")
	attachments := []state.VolumeAttachment{
		&mockVolumeAttachment{VolumeTag: s.volumeTag, MachineTag: machineTag},
		&mockVolumeAttachment{VolumeTag: s.volumeTag, MachineTag: machineTag},
	}
	expectedVolume, err := storage.ConvertStateVolumeToParams(s.api, s.volume)
	c.Assert(err, jc.ErrorIsNil)
	expected := []params.VolumeItem{
		params.VolumeItem{
			Volume:      expectedVolume,
			Attachments: storage.ConvertStateVolumeAttachmentsToParams(attachments)},
	}
	c.Assert(
		storage.GetVolumeItems(s.api, attachments),
		jc.DeepEquals,
		expected)
}