示例#1
0
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.*")
}
示例#2
0
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)
}
示例#3
0
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)
}
示例#4
0
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)
}
示例#5
0
func (s *volumeSuite) TestCreateVolumeItemInvalidTag(c *gc.C) {
	found := storage.CreateVolumeItem(s.api, "666", nil)
	c.Assert(found.Error, gc.ErrorMatches, ".*not a valid tag.*")
}