Skip to content

Conversation

@sashabaranov
Copy link
Owner

Summary

  • increase error accumulator test coverage
  • add form builder createFormFile tests
  • validate RequestBuilder with reader body and header
  • test WrapReader helper

Testing

  • go test ./... -coverprofile=coverage.out

https://chatgpt.com/codex/tasks/task_e_686f9af573a0832597ccc164b5cb56c2

@codecov
Copy link

codecov bot commented Jul 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.26%. Comparing base (c650976) to head (50301c4).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1032      +/-   ##
==========================================
+ Coverage   86.30%   87.26%   +0.96%     
==========================================
  Files          43       43              
  Lines        2387     2387              
==========================================
+ Hits         2060     2083      +23     
+ Misses        302      284      -18     
+ Partials       25       20       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sashabaranov sashabaranov requested a review from Copilot July 10, 2025 13:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances unit test coverage by adding tests for various builder utilities and error accumulation.

  • Adds tests for RequestBuilder with reader bodies and custom headers
  • Covers FormBuilder.createFormFile edge cases (empty filename and write failures)
  • Extends error accumulator tests to ensure buffer errors are propagated
  • Introduces tests for WrapReader helper handling named and anonymous readers

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/request_builder_test.go Added TestRequestBuilderWithReaderBodyAndHeader for body/header handling
internal/form_builder_test.go Added TestCreateFormFile to cover empty filename and writer errors
internal/error_accumulator_test.go Added TestDefaultErrorAccumulator_WriteError to propagate buffer errors
image_test.go Added TestWrapReader to verify reader wrapping of Name/ContentType
Comments suppressed due to low confidence (3)

internal/form_builder_test.go:169

  • TestCreateFormFile checks only that an error is returned for empty filename but doesn't assert that the error is the expected specific error. Consider using checks.ErrorIs to verify the exact error value (e.g., ErrEmptyFilename) to avoid false positives.
	err := builder.createFormFile("file", bytes.NewBufferString("data"), "")

image_test.go:201

  • In the anonymous reader case, the test only verifies Name() but doesn't check ContentType(). To fully cover WrapReader behavior, extend the interface to include ContentType() and assert it returns an empty string.
	f2, ok := wrapped.(interface{ Name() string })

internal/request_builder_test.go:73

  • The test verifies body and header but doesn't assert that the request's Method and URL are set correctly. Consider adding assertions for req.Method and req.URL.String() to fully cover Build behavior.
	req, err := b.Build(ctx, method, url, body, header)

@sashabaranov sashabaranov merged commit 1bf77f6 into master Jul 10, 2025
7 checks passed
Rosenberg96 pushed a commit to lunarway/go-openai that referenced this pull request Aug 18, 2025
* Add unit tests to improve coverage

* Fix type assertion checks in tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants