示例#1
0
func (s *volumeSuite) TestVolumeAttachmentsError(c *gc.C) {
	s.state.volumeAttachments =
		func(volume names.VolumeTag) ([]state.VolumeAttachment, error) {
			return nil, errors.Errorf("not for volume %v", volume)
		}

	found := storage.VolumeAttachments(s.api, []state.Volume{s.volume})
	c.Assert(found, gc.HasLen, 1)
	c.Assert(found[0].Error, gc.ErrorMatches, ".*for volume.*")
}
示例#2
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)
}
示例#3
0
func (s *volumeSuite) TestVolumeAttachmentsEmpty(c *gc.C) {
	s.state.volumeAttachments =
		func(volume names.VolumeTag) ([]state.VolumeAttachment, error) {
			return nil, nil
		}
	expectedVolume, err := storage.ConvertStateVolumeToParams(s.api, s.volume)
	c.Assert(err, jc.ErrorIsNil)
	expected := params.VolumeItem{
		Volume: expectedVolume,
	}

	found := storage.VolumeAttachments(s.api, []state.Volume{s.volume})
	c.Assert(found, gc.HasLen, 1)
	c.Assert(found[0], gc.DeepEquals, expected)
}