api: document client stream behavior with a test (#8996)

Added unit tests to verify error handling behavior in the Client.stream and Client.do methods.
Tests cover various error scenarios including:
- Error responses with status codes >= 400
- Error messages with successful status codes
- Empty error messages
- Successful responses
This commit is contained in:
Bruce MacDonald 2025-02-20 13:19:58 -08:00 committed by GitHub
parent ba9ec3d05e
commit 14b5a9a150
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 211 additions and 1 deletions

View file

@ -132,7 +132,7 @@ func (c *Client) do(ctx context.Context, method, path string, reqData, respData
const maxBufferSize = 512 * format.KiloByte
func (c *Client) stream(ctx context.Context, method, path string, data any, fn func([]byte) error) error {
var buf *bytes.Buffer
var buf io.Reader
if data != nil {
bts, err := json.Marshal(data)
if err != nil {