client: Add Cancel function and tests
NOTE that the tests against the rpmmd fixure for running and waiting are a bit of a kludge. It is impossible to mock up a running or waiting that will allow an actual cancel, so the tests check for the internal server error generated by using the fixure data. Getting this error means that the API code did it's job and tried to cancel the compose so that should be a good compromise.
This commit is contained in:
parent
c657713181
commit
52e9d45e58
2 changed files with 46 additions and 4 deletions
|
|
@ -105,6 +105,20 @@ func GetComposesTypesV0(socket *http.Client) ([]weldr.ComposeTypeV0, *APIRespons
|
|||
return composeTypes.Types, nil, nil
|
||||
}
|
||||
|
||||
// CancelComposeV0 cancels one composes based on the uuid
|
||||
func CancelComposeV0(socket *http.Client, uuid string) (weldr.CancelComposeStatusV0, *APIResponse, error) {
|
||||
body, resp, err := DeleteRaw(socket, "/api/v0/compose/cancel/"+uuid)
|
||||
if resp != nil || err != nil {
|
||||
return weldr.CancelComposeStatusV0{}, resp, err
|
||||
}
|
||||
var status weldr.CancelComposeStatusV0
|
||||
err = json.Unmarshal(body, &status)
|
||||
if err != nil {
|
||||
return weldr.CancelComposeStatusV0{}, nil, err
|
||||
}
|
||||
return status, nil, nil
|
||||
}
|
||||
|
||||
// DeleteComposeV0 deletes one or more composes based on their uuid
|
||||
func DeleteComposeV0(socket *http.Client, uuids string) (weldr.DeleteComposeResponseV0, *APIResponse, error) {
|
||||
body, resp, err := DeleteRaw(socket, "/api/v0/compose/delete/"+uuids)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue