weldr: Improve the error message from sourceNewHandler

This commit is contained in:
Brian C. Lane 2020-03-19 15:56:01 -07:00 committed by Tom Gundersen
parent a87c0ee44d
commit 222d09499c
2 changed files with 14 additions and 4 deletions

View file

@ -827,7 +827,9 @@ func TestSourcesNew(t *testing.T) {
ExpectedStatus int
ExpectedJSON string
}{
{"POST", "/api/v0/projects/source/new", ``, http.StatusBadRequest, `{"errors":[{"code":400,"id":"HTTPError","msg":"Bad Request"}],"status":false}`},
{"POST", "/api/v0/projects/source/new", ``, http.StatusBadRequest, `{"errors": [{"id": "ProjectsError","msg": "Missing source"}],"status":false}`},
// Bad JSON, missing quote after name
{"POST", "/api/v0/projects/source/new", `{"name: "fish","url": "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/","type": "yum-baseurl","check_ssl": false,"check_gpg": false}`, http.StatusBadRequest, `{"errors": [{"id": "ProjectsError","msg": "Problem parsing POST body: invalid character 'f' after object key"}],"status":false}`},
{"POST", "/api/v0/projects/source/new", `{"name": "fish","url": "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/","type": "yum-baseurl","check_ssl": false,"check_gpg": false}`, http.StatusOK, `{"status":true}`},
}