feat(forge): add safe Go stringers
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
a5bc1a3ed8
commit
40934c2e43
4 changed files with 20 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
7
forge.go
7
forge.go
|
|
@ -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() }
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue