backend: membership errorhandling tests
This commit is contained in:
@@ -33,11 +33,12 @@ func (service *MembershipService) UpdateSubscription(subscription *models.Subscr
|
||||
|
||||
existingSubscription, err := repositories.GetSubscriptionByName(&subscription.Name)
|
||||
if err != nil {
|
||||
if err.Error() == "record not found" {
|
||||
return nil, errors.ErrSubscriptionNotFound
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if existingSubscription == nil {
|
||||
return nil, errors.ErrSubscriptionNotFound
|
||||
}
|
||||
|
||||
if existingSubscription.MonthlyFee != subscription.MonthlyFee ||
|
||||
existingSubscription.HourlyRate != subscription.HourlyRate ||
|
||||
existingSubscription.Conditions != subscription.Conditions ||
|
||||
@@ -56,11 +57,12 @@ func (service *MembershipService) DeleteSubscription(id *uint, name *string) err
|
||||
}
|
||||
exists, err := repositories.GetSubscriptionByName(name)
|
||||
if err != nil {
|
||||
if err.Error() == "record not found" {
|
||||
return errors.ErrSubscriptionNotFound
|
||||
}
|
||||
return err
|
||||
}
|
||||
if exists == nil {
|
||||
return errors.ErrNotFound
|
||||
}
|
||||
|
||||
if *id != exists.ID {
|
||||
return errors.ErrInvalidSubscriptionData
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user