package github import ( "net/http" "net/http/httptest" "testing" "time" ) // newTestClient creates a *Client backed by an httptest.Server running the // given handler. The server is automatically closed when the test finishes. // Shared across test files in package github. func newTestClient(t *testing.T, handler http.HandlerFunc) *Client { t.Helper() srv := httptest.NewServer(handler) t.Cleanup(srv.Close) c := NewClient("test-token", srv.URL, AllowInsecureHTTP()) c.SetHTTPClient(srv.Client()) if err := c.SetRetryBackoff([]time.Duration{1 * time.Millisecond, 1 * time.Millisecond}); err != nil { t.Fatalf("SetRetryBackoff: %v", err) } return c }