func (s *volumeSuite) TestCreateVolumeItemNonexistingVolume(c *gc.C) { s.state.volume = func(tag names.VolumeTag) (state.Volume, error) { return s.volume, errors.Errorf("not volume for tag %v", tag) } found := storage.CreateVolumeItem(s.api, names.NewVolumeTag("666").String(), nil) c.Assert(found.Error, gc.ErrorMatches, ".*volume for tag.*") }
func (s *volumeSuite) TestCreateVolumeItem(c *gc.C) { found := storage.CreateVolumeItem(s.api, s.volumeTag.String(), nil) c.Assert(found.Error, gc.IsNil) c.Assert(found.Error, gc.IsNil) expected, err := storage.ConvertStateVolumeToParams(s.api, s.volume) c.Assert(err, jc.ErrorIsNil) c.Assert(found.Volume, gc.DeepEquals, expected) }
func (s *volumeSuite) TestCreateVolumeItemNoStorageInstance(c *gc.C) { s.volume = &mockVolume{tag: s.volumeTag, hasNoStorage: true} found := storage.CreateVolumeItem(s.api, s.volumeTag.String(), nil) c.Assert(found.Error, gc.IsNil) c.Assert(found.Error, gc.IsNil) expected, err := storage.ConvertStateVolumeToParams(s.api, s.volume) c.Assert(err, jc.ErrorIsNil) c.Assert(found.Volume, gc.DeepEquals, expected) }
func (s *volumeSuite) TestCreateVolumeItemNoUnit(c *gc.C) { s.storageInstance.owner = names.NewServiceTag("test-service") found := storage.CreateVolumeItem(s.api, s.volumeTag.String(), nil) c.Assert(found.Error, gc.IsNil) c.Assert(found.Error, gc.IsNil) expected, err := storage.ConvertStateVolumeToParams(s.api, s.volume) c.Assert(err, jc.ErrorIsNil) c.Assert(found.Volume, gc.DeepEquals, expected) }
func (s *volumeSuite) TestCreateVolumeItemInvalidTag(c *gc.C) { found := storage.CreateVolumeItem(s.api, "666", nil) c.Assert(found.Error, gc.ErrorMatches, ".*not a valid tag.*") }