Beispiel #1
0
func (s *volumeSuite) TestFilterVolumesNoItems(c *gc.C) {
	s.state.machineVolumeAttachments =
		func(machine names.MachineTag) ([]state.VolumeAttachment, error) {
			return nil, nil
		}
	filter := params.VolumeFilter{
		Machines: []string{s.machineTag.String()}}

	c.Assert(storage.FilterVolumes(s.api, filter), gc.IsNil)
}
Beispiel #2
0
func (s *volumeSuite) TestFilterVolumesErrorMachineAttachments(c *gc.C) {
	s.state.machineVolumeAttachments =
		func(machine names.MachineTag) ([]state.VolumeAttachment, error) {
			return nil, errors.Errorf("not for machine %v", machine)
		}
	filter := params.VolumeFilter{
		Machines: []string{s.machineTag.String()}}

	found := storage.FilterVolumes(s.api, filter)
	c.Assert(found, gc.HasLen, 1)
	c.Assert(found[0].Error, gc.ErrorMatches, ".*for machine.*")
}
Beispiel #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)
}