Mock the 404 body Gitea really returns
This commit is contained in:
@@ -156,7 +156,7 @@ 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.StatusNotFound)
|
||||
_, _ = io.WriteString(w, `{"message":"pull request does not exist"}`)
|
||||
_, _ = io.WriteString(w, `{"message":"not found","url":"https://git.unkin.net/api/swagger","errors":null}`)
|
||||
})
|
||||
srv := httptest.NewServer(mux)
|
||||
defer srv.Close()
|
||||
@@ -167,7 +167,7 @@ func TestEditPRAPIError(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("expected error on 404")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "pull request does not exist") {
|
||||
if !strings.Contains(err.Error(), `"message":"not found"`) {
|
||||
t.Errorf("error %q should carry the API message", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user