DeleteInstance should noop if error not found
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
4b1d51f1d0
commit
64d1501b0e
2 changed files with 23 additions and 0 deletions
|
|
@ -147,6 +147,9 @@ func (s *sqlDatabase) GetInstanceByName(ctx context.Context, instanceName string
|
|||
func (s *sqlDatabase) DeleteInstance(_ context.Context, poolID string, instanceName string) (err error) {
|
||||
instance, err := s.getPoolInstanceByName(poolID, instanceName)
|
||||
if err != nil {
|
||||
if errors.Is(err, runnerErrors.ErrNotFound) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "deleting instance")
|
||||
}
|
||||
|
||||
|
|
@ -187,6 +190,9 @@ func (s *sqlDatabase) DeleteInstance(_ context.Context, poolID string, instanceN
|
|||
func (s *sqlDatabase) DeleteInstanceByName(ctx context.Context, instanceName string) error {
|
||||
instance, err := s.getInstanceByName(ctx, instanceName)
|
||||
if err != nil {
|
||||
if errors.Is(err, runnerErrors.ErrNotFound) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "deleting instance")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -277,6 +277,23 @@ func (s *InstancesTestSuite) TestDeleteInstance() {
|
|||
|
||||
_, err = s.Store.GetPoolInstanceByName(s.adminCtx, s.Fixtures.Pool.ID, storeInstance.Name)
|
||||
s.Require().Equal("fetching instance: fetching pool instance by name: not found", err.Error())
|
||||
|
||||
err = s.Store.DeleteInstance(s.adminCtx, s.Fixtures.Pool.ID, storeInstance.Name)
|
||||
s.Require().Nil(err)
|
||||
}
|
||||
|
||||
func (s *InstancesTestSuite) TestDeleteInstanceByName() {
|
||||
storeInstance := s.Fixtures.Instances[0]
|
||||
|
||||
err := s.Store.DeleteInstanceByName(s.adminCtx, storeInstance.Name)
|
||||
|
||||
s.Require().Nil(err)
|
||||
|
||||
_, err = s.Store.GetPoolInstanceByName(s.adminCtx, s.Fixtures.Pool.ID, storeInstance.Name)
|
||||
s.Require().Equal("fetching instance: fetching pool instance by name: not found", err.Error())
|
||||
|
||||
err = s.Store.DeleteInstanceByName(s.adminCtx, storeInstance.Name)
|
||||
s.Require().Nil(err)
|
||||
}
|
||||
|
||||
func (s *InstancesTestSuite) TestDeleteInstanceInvalidPoolID() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue