weldr: change all OSTree related error IDs to OSTreeOptionsError
These will all be reported from the same validation function.
This commit is contained in:
parent
26468315ab
commit
4d31c8e69d
2 changed files with 4 additions and 4 deletions
|
|
@ -2229,7 +2229,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
cr.OSTree.Ref = imageType.OSTreeRef()
|
||||
} else if !ostree.VerifyRef(cr.OSTree.Ref) {
|
||||
errors := responseError{
|
||||
ID: "InvalidChars",
|
||||
ID: "OSTreeOptionsError",
|
||||
Msg: "Invalid ostree ref",
|
||||
}
|
||||
statusResponseError(writer, http.StatusBadRequest, errors)
|
||||
|
|
@ -2278,7 +2278,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
parent, err = ostree.ResolveRef(cr.OSTree.URL, cr.OSTree.Ref)
|
||||
if err != nil {
|
||||
errors := responseError{
|
||||
ID: "OSTreeCommitError",
|
||||
ID: "OSTreeOptionsError",
|
||||
Msg: err.Error(),
|
||||
}
|
||||
statusResponseError(writer, http.StatusBadRequest, errors)
|
||||
|
|
|
|||
|
|
@ -819,9 +819,9 @@ func TestCompose(t *testing.T) {
|
|||
// Ref + URL = OK
|
||||
{false, "POST", "/api/v1/compose?test=2", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"","url":"http://ostree/"}}`, test_distro.TestImageTypeName), http.StatusOK, `{"status": true}`, expectedComposeOSTreeURL, []string{"build_id"}},
|
||||
// Ref + invalid URL = error
|
||||
{false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"","url":"invalid-url"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeCommitError","msg":"Get \"invalid-url/refs/heads/refid\": unsupported protocol scheme \"\""}]}`, nil, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"","url":"invalid-url"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeOptionsError","msg":"Get \"invalid-url/refs/heads/refid\": unsupported protocol scheme \"\""}]}`, nil, []string{"build_id"}},
|
||||
// Bad Ref + URL = error
|
||||
{false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"/bad/ref","parent":"","url":"http://ostree/"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"InvalidChars","msg":"Invalid ostree ref"}]}`, expectedComposeOSTreeURL, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"/bad/ref","parent":"","url":"http://ostree/"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeOptionsError","msg":"Invalid ostree ref"}]}`, expectedComposeOSTreeURL, []string{"build_id"}},
|
||||
// Ref + Parent + URL = error
|
||||
{false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"parentid","url":"http://ostree/"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeOptionsError","msg":"Supply at most one of Parent and URL"}]}`, expectedComposeOSTreeRef, []string{"build_id"}},
|
||||
// Parent + URL = error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue