jobqueue: add back tests for the API

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2019-10-06 00:11:22 +02:00 committed by Lars Karlitski
parent 94e1e6f42b
commit 7e78b4051d
2 changed files with 83 additions and 19 deletions

View file

@ -122,8 +122,20 @@ func (api *API) updateJobHandler(writer http.ResponseWriter, request *http.Reque
err = json.NewDecoder(request.Body).Decode(&body)
if err != nil {
statusResponseError(writer, http.StatusBadRequest, "invalid status: "+err.Error())
return
}
api.store.UpdateCompose(id, body.Status)
err = api.store.UpdateCompose(id, body.Status)
if err != nil {
switch err.(type) {
case *store.NotFoundError:
statusResponseError(writer, http.StatusNotFound, err.Error())
case *store.NotPendingError:
statusResponseError(writer, http.StatusBadRequest, err.Error())
case *store.InvalidRequestError:
statusResponseError(writer, http.StatusBadRequest, err.Error())
}
return
}
statusResponseOK(writer)
}