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": {
|
||||
"description": "Delete a row from ` + "`" + `current` + "`" + ` by ID.",
|
||||
"description": "Delete a row from ` + "`" + `current_archive` + "`" + ` by ID.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"shows"
|
||||
],
|
||||
"summary": "Delete show",
|
||||
"summary": "Delete archived show",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
|
||||
@ -392,14 +392,14 @@
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"description": "Delete a row from `current` by ID.",
|
||||
"description": "Delete a row from `current_archive` by ID.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"shows"
|
||||
],
|
||||
"summary": "Delete show",
|
||||
"summary": "Delete archived show",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
|
||||
@ -409,7 +409,7 @@ paths:
|
||||
- auth
|
||||
/api/v1/shows:
|
||||
delete:
|
||||
description: Delete a row from `current` by ID.
|
||||
description: Delete a row from `current_archive` by ID.
|
||||
parameters:
|
||||
- description: Show ID
|
||||
format: int64
|
||||
@ -434,7 +434,7 @@ paths:
|
||||
description: delete failed
|
||||
schema:
|
||||
$ref: '#/definitions/httpapi.HTTPError'
|
||||
summary: Delete show
|
||||
summary: Delete archived show
|
||||
tags:
|
||||
- shows
|
||||
get:
|
||||
|
||||
@ -270,8 +270,8 @@ func listShowsHandler(svc episode.UseCases) gin.HandlerFunc {
|
||||
}
|
||||
|
||||
// deleteShowHandler godoc
|
||||
// @Summary Delete show
|
||||
// @Description Delete a row from `current` by ID.
|
||||
// @Summary Delete archived show
|
||||
// @Description Delete a row from `current_archive` by ID.
|
||||
// @Tags shows
|
||||
// @Produce json
|
||||
// @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 {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ func TestPGXEpisodeRepo_Delete(t *testing.T) {
|
||||
t.Run("not found", func(t *testing.T) {
|
||||
fp := &fakePool{
|
||||
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)
|
||||
}
|
||||
return pgconn.NewCommandTag("DELETE 0"), nil
|
||||
@ -32,9 +32,13 @@ func TestPGXEpisodeRepo_Delete(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("ok", func(t *testing.T) {
|
||||
var gotID int64
|
||||
var (
|
||||
gotSQL string
|
||||
gotID int64
|
||||
)
|
||||
fp := &fakePool{
|
||||
execFn: func(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error) {
|
||||
gotSQL = sql
|
||||
gotID = args[0].(int64)
|
||||
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 {
|
||||
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 {
|
||||
t.Fatalf("expected id 22, got %d", gotID)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user