feat(forge): expose top-level client metadata
All checks were successful
Security Scan / security (push) Successful in 14s
Test / test (push) Successful in 1m49s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-02 07:26:13 +00:00
parent f8224ed05d
commit 84d7c6a796
2 changed files with 28 additions and 0 deletions

View file

@ -71,3 +71,17 @@ func NewForge(url, token string, opts ...Option) *Forge {
//
// client := f.Client()
func (f *Forge) Client() *Client { return f.client }
// BaseURL returns the configured Forgejo base URL.
//
// Usage:
//
// baseURL := f.BaseURL()
func (f *Forge) BaseURL() string { return f.client.BaseURL() }
// RateLimit returns the last known rate limit information.
//
// Usage:
//
// rl := f.RateLimit()
func (f *Forge) RateLimit() RateLimit { return f.client.RateLimit() }

View file

@ -38,6 +38,20 @@ func TestForge_Client_Good(t *testing.T) {
}
}
func TestForge_BaseURL_Good(t *testing.T) {
f := NewForge("https://forge.lthn.ai", "tok")
if got := f.BaseURL(); got != "https://forge.lthn.ai" {
t.Fatalf("got base URL %q", got)
}
}
func TestForge_RateLimit_Good(t *testing.T) {
f := NewForge("https://forge.lthn.ai", "tok")
if got := f.RateLimit(); got != (RateLimit{}) {
t.Fatalf("got rate limit %#v", got)
}
}
func TestRepoService_ListOrgRepos_Good(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {