Reject an empty pr edit title Gitea would ignore
This commit is contained in:
@@ -155,19 +155,19 @@ func TestEditPRSendsOnlySuppliedFields(t *testing.T) {
|
||||
func TestEditPRAPIError(t *testing.T) {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/api/v1/repos/unkin/repo/pulls/7", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
_, _ = io.WriteString(w, `{"message":"title cannot be empty"}`)
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
_, _ = io.WriteString(w, `{"message":"pull request does not exist"}`)
|
||||
})
|
||||
srv := httptest.NewServer(mux)
|
||||
defer srv.Close()
|
||||
|
||||
title := ""
|
||||
title := "new title"
|
||||
c := &GiteaClient{BaseURL: srv.URL, Token: "t", HTTP: srv.Client()}
|
||||
_, err := c.EditPR("unkin/repo", 7, EditPROptions{Title: &title})
|
||||
if err == nil {
|
||||
t.Fatal("expected error on 422")
|
||||
t.Fatal("expected error on 404")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "title cannot be empty") {
|
||||
if !strings.Contains(err.Error(), "pull request does not exist") {
|
||||
t.Errorf("error %q should carry the API message", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user