feat: add a new command - group delete #16

Merged
Kichiyaki merged 3 commits from feat/new-command-group-delete into master 2022-10-12 05:19:07 +00:00
2 changed files with 11 additions and 0 deletions
Showing only changes of commit bf2d25d7d7 - Show all commits

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()