feat(forge): expose top-level client metadata
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
f8224ed05d
commit
84d7c6a796
2 changed files with 28 additions and 0 deletions
14
forge.go
14
forge.go
|
|
@ -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() }
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue