-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
test: enhance error accumulator and form builder tests, add marshaller tests #999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #999 +/- ##
==========================================
+ Coverage 85.93% 86.48% +0.54%
==========================================
Files 43 43
Lines 2268 2271 +3
==========================================
+ Hits 1949 1964 +15
+ Misses 300 287 -13
- Partials 19 20 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 test coverage for the JSON marshaller/unmarshaler, error accumulator, and form builder modules by introducing additional edge case tests and refining error handling.
- Adds tests for valid and invalid JSON (un)marshalling
- Introduces extensive tests for form builder functionality including file uploads, special characters, and error propagation
- Refactors error accumulator tests to verify multiple write scenarios
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/unmarshaler_test.go | New tests for JSON unmarshalling including normal, invalid, and nil inputs. |
internal/marshaller_test.go | New tests for JSON marshalling with normal, invalid, and empty values. |
internal/form_builder_test.go | Additional tests for form builder behavior in various scenarios. |
internal/form_builder.go | Adds an error check in WriteField to disallow an empty fieldname. |
internal/error_accumulator_test.go | Refactored tests to verify error accumulation behavior. |
Comments suppressed due to low confidence (1)
internal/form_builder_test.go:44
- The code references errors.New but does not import the 'errors' package, which may result in a compilation failure. Please add 'import "errors"' to the import block.
errorMock := errors.New("mock close error")
There was a problem hiding this 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 test coverage for error accumulation, form building, and marshalling behavior by adding new test cases and edge case verifications.
- Added tests for JSON unmarshalling/marshalling functionality covering normal, invalid, and empty input scenarios.
- Extended form builder tests to include multiple file uploads, special characters, concurrent file handling, and field edge cases.
- Updated error accumulator tests to validate sequential error writes and buffer initialization.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
internal/unmarshaler_test.go | New tests for verifying correct and erroneous JSON unmarshalling behavior. |
internal/marshaller_test.go | New tests for validating JSON marshalling, including handling of unsupported types & nil. |
internal/form_builder_test.go | Extended tests covering file uploads, field writing errors, and special filename handling. |
internal/form_builder.go | Added a check to ensure field names are not empty in WriteField. |
internal/error_accumulator_test.go | Updated tests to verify multiple error writes and correct initial buffer state. |
Comments suppressed due to low confidence (1)
internal/error_accumulator_test.go:18
- [nitpick] Ensure that the concatenation order of error messages in the accumulator is guaranteed by design; if not, consider adding a delimiter or additional checks in the test.
expected := "{\"error\": \"test1\"}{\"error\": \"test2\"}"
There was a problem hiding this 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 test coverage by adding new tests for the error accumulator, form builder, and marshaller, and by improving existing tests for JSON unmarshaling.
- Added tests for normal, invalid, and edge case scenarios for JSON unmarshaler and marshaller.
- Extended form builder tests to cover file uploads, content type validation, and error propagation.
- Updated error accumulator tests for improved error concatenation validation.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
internal/unmarshaler_test.go | Tests verifying correct JSON unmarshaling behavior in various cases. |
internal/marshaller_test.go | Tests validating JSON marshalling including handling of invalid inputs. |
internal/form_builder_test.go | New tests covering form builder behaviors like file uploads and error handling. |
internal/form_builder.go | Added fieldname validation to prevent empty field names. |
internal/error_accumulator_test.go | Updated tests for error accumulation and concatenation behavior. |
body := &bytes.Buffer{} | ||
builder := NewFormBuilder(body) | ||
|
||
t.Run("MultipleFiles", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider initializing a new FormBuilder within each subtest in TestMultiPartFormUploads to avoid potential side-effects from sharing mutable state across subtests.
body := &bytes.Buffer{} | |
builder := NewFormBuilder(body) | |
t.Run("MultipleFiles", func(t *testing.T) { | |
t.Run("MultipleFiles", func(t *testing.T) { | |
body := &bytes.Buffer{} | |
builder := NewFormBuilder(body) |
Copilot uses AI. Check for mistakes.
Describe the change
enhance error accumulator and form builder tests, add marshaller tests
Describe your solution
added some edge case tests to improve test coverage
Issue: #997