feat: add a new command - group delete
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
Dawid Wysokiński 2022-10-12 07:17:16 +02:00
parent 99c3b8922b
commit bf2d25d7d7
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
2 changed files with 11 additions and 0 deletions

View File

@ -86,6 +86,10 @@ func (g *Group) List(ctx context.Context, params domain.ListGroupsParams) ([]dom
}
func (g *Group) Delete(ctx context.Context, id, serverID string) error {
if _, err := uuid.Parse(id); err != nil {
return domain.GroupNotFoundError{ID: id}
}
res, err := g.db.NewDelete().
Model(&model.Group{}).
Returning("NULL").

View File

@ -210,6 +210,13 @@ func TestGroup_Delete(t *testing.T) {
assert.Len(t, groups, 0)
})
t.Run("ERR: invalid UUID", func(t *testing.T) {
t.Parallel()
id := "12345"
assert.ErrorIs(t, repo.Delete(context.Background(), id, ""), domain.GroupNotFoundError{ID: id})
})
t.Run("ERR: group not found (unknown ID)", func(t *testing.T) {
t.Parallel()