Skip to content

Commit

Permalink
Return an empty array if no tasks are available
Browse files Browse the repository at this point in the history
All other api endpoints also send empty arrays instead of nil.
Closes #1123
  • Loading branch information
randombenj committed Nov 17, 2022
1 parent e90ac67 commit 71fd730
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ func (s *TaskSuite) TestTasksClear(c *C) {
c.Check(response.Code, Equals, 200)
response, _ = s.HTTPRequest("GET", "/api/tasks", nil)
c.Check(response.Code, Equals, 200)
c.Check(response.Body.String(), Equals, "null")
c.Check(response.Body.String(), Equals, "[]")
}
2 changes: 1 addition & 1 deletion task/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewList() *List {

// GetTasks gets complete list of tasks
func (list *List) GetTasks() []Task {
var tasks []Task
tasks := []Task{}
list.Lock()
for _, task := range list.tasks {
tasks = append(tasks, *task)
Expand Down

0 comments on commit 71fd730

Please sign in to comment.