mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: delete aria2 record in client side (#335)
This commit is contained in:
@@ -109,3 +109,8 @@ func (task *Download) GetOwner() *User {
|
||||
}
|
||||
return task.User
|
||||
}
|
||||
|
||||
// Delete 删除离线下载记录
|
||||
func (download *Download) Delete() error {
|
||||
return DB.Model(download).Delete(download).Error
|
||||
}
|
||||
|
||||
@@ -161,3 +161,19 @@ func TestGetDownloadsByStatusAndUser(t *testing.T) {
|
||||
asserts.Len(res, 2)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownload_Delete(t *testing.T) {
|
||||
asserts := assert.New(t)
|
||||
share := Download{}
|
||||
|
||||
{
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectExec("UPDATE(.+)").
|
||||
WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
mock.ExpectCommit()
|
||||
err := share.Delete()
|
||||
asserts.NoError(mock.ExpectationsWereMet())
|
||||
asserts.NoError(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user