feat(tools): pr_list

This commit is contained in:
Mathias Bergqvist
2026-05-06 22:46:11 +02:00
parent ddfcc32afd
commit 388131c8cd
4 changed files with 187 additions and 0 deletions

View File

@@ -136,3 +136,21 @@ func TestGetPullRequestDiff(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, []byte(rawDiff), diff)
}
func TestListPullRequests(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "/api/v1/repos/o/r/pulls", r.URL.Path)
assert.Equal(t, "open", r.URL.Query().Get("state"))
assert.Equal(t, "feat/x", r.URL.Query().Get("head"))
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`[` + pullFixture + `]`))
}))
defer srv.Close()
c := gitea.NewClient(srv.URL, "tok")
prs, err := c.ListPullRequests(context.Background(), "o", "r", "open", "feat/x", 0, 0)
require.NoError(t, err)
require.Len(t, prs, 1)
assert.Equal(t, 7, prs[0].Number)
assert.Equal(t, "feat/x", prs[0].Head.Ref)
}