Added tests to get all task attachments
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kolaente 2019-10-13 13:28:36 +02:00
parent f11e889102
commit 8ebb2de0c6
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 8 additions and 2 deletions

View File

@ -94,7 +94,8 @@ func (ta *TaskAttachment) ReadAll(s string, a web.Auth, page int) (interface{},
err := x.
Limit(getLimitFromPageIndex(page)).
Find(attachments)
Where("task_id = ?", ta.TaskID).
Find(&attachments)
if err != nil {
return nil, err
}

View File

@ -110,7 +110,12 @@ func TestTaskAttachment_NewAttachment(t *testing.T) {
}
func TestTaskAttachment_ReadAll(t *testing.T) {
// Assert all files are loaded correctly with their actual files
ta := &TaskAttachment{TaskID: 1}
as, err := ta.ReadAll("", &User{ID: 1}, 0)
attachments, _ := as.([]*TaskAttachment)
assert.NoError(t, err)
assert.Len(t, attachments, 3)
assert.Equal(t, "test", attachments[0].File.Name)
}
func TestTaskAttachment_Delete(t *testing.T) {