Skip to content

Commit

Permalink
fix(be): delete schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Sep 9, 2021
1 parent 7ca8da1 commit 1d72c32
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .dredd/hooks/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// STATE
// Runtime created objects we needs to reference in test setups
// Runtime created objects we need to reference in test setups
var testRunnerUser *db.User
var userPathTestUser *db.User
var userProject *db.Project
Expand Down
4 changes: 4 additions & 0 deletions .dredd/hooks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ func main() {
h.Before("project > /api/project/{project_id}/tasks/{task_id} > Deletes task (including output) > 204 > application/json", capabilityWrapper("task"))
h.Before("project > /api/project/{project_id}/tasks/{task_id}/output > Get task output > 200 > application/json", capabilityWrapper("task"))

h.Before("schedule > /api/project/{project_id}/schedules/{schedule_id} > Get schedule > 200 > application/json", capabilityWrapper("schedule"))
h.Before("schedule > /api/project/{project_id}/schedules/{schedule_id} > Updates schedule > 204 > application/json", capabilityWrapper("schedule"))
h.Before("schedule > /api/project/{project_id}/schedules/{schedule_id} > Deletes schedule > 204 > application/json", capabilityWrapper("schedule"))

//Add these last as they normalize the requests and path values after hook processing
h.BeforeAll(func(transactions []*trans.Transaction) {
for _, t := range transactions {
Expand Down
57 changes: 41 additions & 16 deletions api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,13 @@ parameters:
type: integer
required: true
x-example: 8
schedule_id:
name: schedule_id
description: schedule ID
in: path
type: integer
required: true
x-example: 9
paths:
/ping:
get:
Expand Down Expand Up @@ -509,22 +516,6 @@ paths:
schema:
$ref: "#/definitions/InfoType"

# /upgrade:
# get:
# summary: Check if new updates available and fetch /info
# responses:
# 204:
# description: no update
# 200:
# description: ok
# schema:
# $ref: "#/definitions/InfoType"
# post:
# summary: Upgrade the server
# responses:
# 200:
# description: Server binary was replaced by new version, server has shut down.

# Authentication
/auth/login:
post:
Expand Down Expand Up @@ -1228,6 +1219,40 @@ paths:


# project schedules
/project/{project_id}/schedules/{schedule_id}:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/schedule_id"
get:
tags:
- schedule
summary: Get schedule
responses:
200:
description: Schedule
schema:
$ref: "#/definitions/Schedule"
delete:
tags:
- schedule
summary: Deletes schedule
responses:
204:
description: schedule deleted
put:
tags:
- schedule
summary: Updates schedule
parameters:
- name: schedule
in: body
required: true
schema:
$ref: "#/definitions/ScheduleRequest"
responses:
204:
description: schedule updated

/project/{project_id}/schedules:
parameters:
- $ref: "#/parameters/project_id"
Expand Down
2 changes: 1 addition & 1 deletion db/sql/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (d *SqlDb) GetSchedule(projectID int, scheduleID int) (template db.Schedule
}

func (d *SqlDb) DeleteSchedule(projectID int, scheduleID int) error {
_, err := d.exec("delete project__schedule where project_id=? and id=?", projectID, scheduleID)
_, err := d.exec("delete from project__schedule where project_id=? and id=?", projectID, scheduleID)
return err
}

Expand Down

0 comments on commit 1d72c32

Please sign in to comment.