feat(forge): add safe Go stringers
All checks were successful
Security Scan / security (push) Successful in 16s
Test / test (push) Successful in 1m40s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-02 07:48:37 +00:00
parent a5bc1a3ed8
commit 40934c2e43
4 changed files with 20 additions and 0 deletions

View file

@ -172,6 +172,13 @@ func (c *Client) String() string {
return core.Concat("forge.Client{baseURL=", strconv.Quote(c.baseURL), ", token=", tokenState, ", userAgent=", strconv.Quote(c.userAgent), "}")
}
// GoString returns a safe Go-syntax summary of the client configuration.
//
// Usage:
//
// s := fmt.Sprintf("%#v", client)
func (c *Client) GoString() string { return c.String() }
// HasToken reports whether the client was configured with an API token.
//
// Usage:

View file

@ -236,6 +236,9 @@ func TestClient_String_Good(t *testing.T) {
if got := c.String(); got != want {
t.Fatalf("got String()=%q, want %q", got, want)
}
if got := fmt.Sprintf("%#v", c); got != want {
t.Fatalf("got GoString=%q, want %q", got, want)
}
}
func TestAPIError_Error_Good(t *testing.T) {

View file

@ -119,3 +119,10 @@ func (f *Forge) HasToken() bool { return f.client.HasToken() }
func (f *Forge) String() string {
return "forge.Forge{" + f.client.String() + "}"
}
// GoString returns a safe Go-syntax summary of the Forge client.
//
// Usage:
//
// s := fmt.Sprintf("%#v", f)
func (f *Forge) GoString() string { return f.String() }

View file

@ -92,6 +92,9 @@ func TestForge_String_Good(t *testing.T) {
if got := f.String(); got != want {
t.Fatalf("got String()=%q, want %q", got, want)
}
if got := fmt.Sprintf("%#v", f); got != want {
t.Fatalf("got GoString=%q, want %q", got, want)
}
}
func TestRepoService_ListOrgRepos_Good(t *testing.T) {