Changed the perma delete endpoint to target archive instead of current
This commit is contained in:
parent
8c2ea2b0d0
commit
e7aa62358c
@ -394,14 +394,14 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"description": "Delete a row from ` + "`" + `current` + "`" + ` by ID.",
|
"description": "Delete a row from ` + "`" + `current_archive` + "`" + ` by ID.",
|
||||||
"produces": [
|
"produces": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"shows"
|
"shows"
|
||||||
],
|
],
|
||||||
"summary": "Delete show",
|
"summary": "Delete archived show",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
|||||||
@ -392,14 +392,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"description": "Delete a row from `current` by ID.",
|
"description": "Delete a row from `current_archive` by ID.",
|
||||||
"produces": [
|
"produces": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"shows"
|
"shows"
|
||||||
],
|
],
|
||||||
"summary": "Delete show",
|
"summary": "Delete archived show",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
|||||||
@ -409,7 +409,7 @@ paths:
|
|||||||
- auth
|
- auth
|
||||||
/api/v1/shows:
|
/api/v1/shows:
|
||||||
delete:
|
delete:
|
||||||
description: Delete a row from `current` by ID.
|
description: Delete a row from `current_archive` by ID.
|
||||||
parameters:
|
parameters:
|
||||||
- description: Show ID
|
- description: Show ID
|
||||||
format: int64
|
format: int64
|
||||||
@ -434,7 +434,7 @@ paths:
|
|||||||
description: delete failed
|
description: delete failed
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/httpapi.HTTPError'
|
$ref: '#/definitions/httpapi.HTTPError'
|
||||||
summary: Delete show
|
summary: Delete archived show
|
||||||
tags:
|
tags:
|
||||||
- shows
|
- shows
|
||||||
get:
|
get:
|
||||||
|
|||||||
@ -270,8 +270,8 @@ func listShowsHandler(svc episode.UseCases) gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// deleteShowHandler godoc
|
// deleteShowHandler godoc
|
||||||
// @Summary Delete show
|
// @Summary Delete archived show
|
||||||
// @Description Delete a row from `current` by ID.
|
// @Description Delete a row from `current_archive` by ID.
|
||||||
// @Tags shows
|
// @Tags shows
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param id query int64 true "Show ID"
|
// @Param id query int64 true "Show ID"
|
||||||
|
|||||||
@ -290,7 +290,7 @@ func (r *pgxEpisodeRepo) MoveToArchive(ctx context.Context, ids []int64) (episod
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *pgxEpisodeRepo) Delete(ctx context.Context, id int64) error {
|
func (r *pgxEpisodeRepo) Delete(ctx context.Context, id int64) error {
|
||||||
cmdTag, err := r.pool.Exec(ctx, `DELETE FROM current WHERE id = $1`, id)
|
cmdTag, err := r.pool.Exec(ctx, `DELETE FROM current_archive WHERE id = $1`, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ func TestPGXEpisodeRepo_Delete(t *testing.T) {
|
|||||||
t.Run("not found", func(t *testing.T) {
|
t.Run("not found", func(t *testing.T) {
|
||||||
fp := &fakePool{
|
fp := &fakePool{
|
||||||
execFn: func(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error) {
|
execFn: func(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error) {
|
||||||
if sql != `DELETE FROM current WHERE id = $1` {
|
if sql != `DELETE FROM current_archive WHERE id = $1` {
|
||||||
t.Fatalf("unexpected sql: %s", sql)
|
t.Fatalf("unexpected sql: %s", sql)
|
||||||
}
|
}
|
||||||
return pgconn.NewCommandTag("DELETE 0"), nil
|
return pgconn.NewCommandTag("DELETE 0"), nil
|
||||||
@ -32,9 +32,13 @@ func TestPGXEpisodeRepo_Delete(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("ok", func(t *testing.T) {
|
t.Run("ok", func(t *testing.T) {
|
||||||
var gotID int64
|
var (
|
||||||
|
gotSQL string
|
||||||
|
gotID int64
|
||||||
|
)
|
||||||
fp := &fakePool{
|
fp := &fakePool{
|
||||||
execFn: func(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error) {
|
execFn: func(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error) {
|
||||||
|
gotSQL = sql
|
||||||
gotID = args[0].(int64)
|
gotID = args[0].(int64)
|
||||||
return pgconn.NewCommandTag("DELETE 1"), nil
|
return pgconn.NewCommandTag("DELETE 1"), nil
|
||||||
},
|
},
|
||||||
@ -43,6 +47,9 @@ func TestPGXEpisodeRepo_Delete(t *testing.T) {
|
|||||||
if err := repo.Delete(context.Background(), 22); err != nil {
|
if err := repo.Delete(context.Background(), 22); err != nil {
|
||||||
t.Fatalf("unexpected err: %v", err)
|
t.Fatalf("unexpected err: %v", err)
|
||||||
}
|
}
|
||||||
|
if gotSQL != `DELETE FROM current_archive WHERE id = $1` {
|
||||||
|
t.Fatalf("expected archive delete sql, got %s", gotSQL)
|
||||||
|
}
|
||||||
if gotID != 22 {
|
if gotID != 22 {
|
||||||
t.Fatalf("expected id 22, got %d", gotID)
|
t.Fatalf("expected id 22, got %d", gotID)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user