Mock the 404 body Gitea really returns
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

This commit is contained in:
2026-09-19 12:44:00 +10:00
parent 78d83b7a61
commit 3f990c841d
+2 -2
View File
@@ -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)
}
}