fix: address verified review findings (pulls-1)

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 17:39:24 +02:00
1 parent 58f0fc4bf9
commit 401650b489
15 files changed
+202 -8

No files matched your search

+29
View File
@@ -58,6 +58,35 @@ func TestCheckWatchRevalidatesHeadBeforeReturning(t *testing.T) {
require.Equal(t, 5, heads)
}
func TestCheckWatchReportsTheEmptyStateOnce(t *testing.T) {
polls := 0
client := newTestClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.Contains(r.URL.Path, "/pulls/") {
_, _ = w.Write([]byte(`{"head":{"sha":"abc"}}`))
return
}
if r.URL.Query().Get("page") != "1" {
_, _ = w.Write([]byte(`[]`))
return
}
polls++
if polls < 3 {
_, _ = w.Write([]byte(`[]`))
return
}
_, _ = w.Write([]byte(`[{"id":1,"context":"build","status":"success"}]`))
}))
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
var reported []int
_, err := (Pulls{Client: client, Repository: "owner/repo"}).WatchChecks(ctx, 7, time.Millisecond, func(items []Check) error {
reported = append(reported, len(items))
return nil
})
require.NoError(t, err)
require.Equal(t, []int{0, 1}, reported)
}
func TestCheckWatchTreatsSkippedAsPassing(t *testing.T) {
snapshots := 0
client := newTestClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {