예제 #1
0
func (s *volumeSuite) TestListVolumeAttachmentsEmpty(c *gc.C) {
	s.state.allVolumes =
		func() ([]state.Volume, error) {
			return nil, nil
		}
	items, err := storage.ListVolumeAttachments(s.api)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(items, gc.IsNil)
}
예제 #2
0
func (s *volumeSuite) TestListVolumeAttachmentsError(c *gc.C) {
	msg := "inventing error"
	s.state.allVolumes =
		func() ([]state.Volume, error) {
			return nil, errors.New(msg)
		}
	items, err := storage.ListVolumeAttachments(s.api)
	c.Assert(errors.Cause(err), gc.ErrorMatches, msg)
	c.Assert(items, gc.IsNil)
}
예제 #3
0
func (s *volumeSuite) TestListVolumeAttachments(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},
		),
	}

	items, err := storage.ListVolumeAttachments(s.api)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(items, gc.HasLen, 1)
	c.Assert(items[0], gc.DeepEquals, expected)
}