Return an empty array if no tasks are available

All other api endpoints also send empty arrays instead of nil.
Closes #1123
This commit is contained in:
Benj Fassbind
2022-11-17 10:10:48 +01:00
parent e90ac6767f
commit 71fd730598
2 changed files with 2 additions and 2 deletions

View File

@@ -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, "[]")
}

View File

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