PLT-7759: Make GetNewestJobByStatusAndType not fail when no jobs match. (#7540)

This commit is contained in:
George Goldberg
2017-10-02 14:15:51 +01:00
committed by Harrison Healey
parent 76bd1bb212
commit 078467ee96
2 changed files with 6 additions and 2 deletions

View File

@@ -344,8 +344,8 @@ func (jss SqlJobStore) GetNewestJobByStatusAndType(status string, jobType string
Type = :Type
ORDER BY
CreateAt DESC
LIMIT 1`, map[string]interface{}{"Status": status, "Type": jobType}); err != nil {
result.Err = model.NewAppError("SqlJobStore.GetAllByStatus", "store.sql_job.get_newest_job_by_status_and_type.app_error", nil, "Status="+status+", "+err.Error(), http.StatusInternalServerError)
LIMIT 1`, map[string]interface{}{"Status": status, "Type": jobType}); err != nil && err != sql.ErrNoRows {
result.Err = model.NewAppError("SqlJobStore.GetNewestJobByStatusAndType", "store.sql_job.get_newest_job_by_status_and_type.app_error", nil, "Status="+status+", "+err.Error(), http.StatusInternalServerError)
} else {
result.Data = job
}

View File

@@ -275,6 +275,10 @@ func TestJobStoreGetNewestJobByStatusAndType(t *testing.T) {
result := <-ss.Job().GetNewestJobByStatusAndType(status1, jobType1)
assert.Nil(t, result.Err)
assert.EqualValues(t, jobs[0].Id, result.Data.(*model.Job).Id)
result = <-ss.Job().GetNewestJobByStatusAndType(model.NewId(), model.NewId())
assert.Nil(t, result.Err)
assert.Nil(t, result.Data.(*model.Job))
}
func TestJobStoreGetCountByStatusAndType(t *testing.T) {