-
Notifications
You must be signed in to change notification settings - Fork 1
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
Update module github.com/stretchr/testify to v1.10.0 #4
base: main
Are you sure you want to change the base?
Update module github.com/stretchr/testify to v1.10.0 #4
Conversation
Reviewer's Guide by SourceryThis PR updates the github.com/stretchr/testify module from v1.8.4 to v1.10.0. The update includes new assertion functions, bug fixes, documentation improvements, and build/CI enhancements. The changes span across multiple files in the assert, require, and mock subpackages, as well as updates to the go.mod and go.sum files. No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
🚨 gitStream Monthly Automation Limit Reached 🚨 Your organization has exceeded the number of pull requests allowed for automation with gitStream. To continue automating your PR workflows and unlock additional features, please contact LinearB. |
WalkthroughThis pull request updates the Go module dependencies and refactors several assertion functions across the testify framework. The dependency version has been bumped from v1.8.4 to v1.10.0 with a Go version adjustment. Comparison functions now use a new type alias ( Changes
Sequence Diagram(s)sequenceDiagram
participant T as Test
participant H as HTTP Handler
participant A as HTTP Assertion (e.g., HTTPSuccess)
participant R as Request Builder
T->>A: Call HTTPSuccess(handler, method, URL, values, msgAndArgs)
A->>R: Create HTTP Request (using http.NoBody)
R->>H: Forward request
H->>A: Return HTTP Response
A->>T: Assert status code and report result
sequenceDiagram
participant T as Test
participant A as NotElementsMatch Assertion
participant C as Comparison Logic
T->>A: Invoke NotElementsMatch(listA, listB, msgAndArgs)
A->>C: Perform unordered element comparison
C-->>A: Return mismatch result
A->>T: Assertion passes/fails accordingly
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (7)
vendor/github.com/stretchr/testify/assert/assertion_compare.go (1)
359-378
: Add documentation for uintptr support.While the implementation is correct, it would be helpful to add a comment explaining why uintptr comparison support was added and its use cases.
case reflect.Uintptr: + // Support comparison of uintptr values, useful for comparing memory addresses {
vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go (1)
25-25
: Consider adding a default panic handler for uninitialized Unmarshal.The
Unmarshal
variable is not initialized, which could lead to nil pointer panics if users forget to set it. Consider initializing it with a function that panics with a helpful message.-var Unmarshal func(in []byte, out interface{}) error +var Unmarshal = func(in []byte, out interface{}) error { + panic("yaml.Unmarshal not initialized. Please set yaml.Unmarshal in your init() function when using testify_yaml_custom build tag") +}vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go (2)
4-30
: Consider enhancing documentation with license implications.The documentation is comprehensive and well-structured. Consider adding a note about potential license implications when choosing alternative YAML implementations, as this was one of the motivations for making YAML handling pluggable (referenced in PR #1120).
32-37
: Consider using a more descriptive import alias.The implementation is clean and correct. Consider using a more descriptive import alias like
yamlv3
instead ofgoyaml
to better indicate the version.-import goyaml "gopkg.in/yaml.v3" +import yamlv3 "gopkg.in/yaml.v3" func Unmarshal(in []byte, out interface{}) error { - return goyaml.Unmarshal(in, out) + return yamlv3.Unmarshal(in, out) }vendor/github.com/stretchr/testify/assert/assertions.go (2)
154-155
: Marking function as deprecated.The deprecation note is clear: ensure any internal usage of
ObjectsExportedFieldsAreEqual
is migrated toEqualExportedValues
to avoid confusion.
781-789
: SafergetLen
with panic recovery.Wrapping
v.Len()
in arecover()
block prevents unexpected panics. This is especially useful for types that don’t supportlen()
.vendor/github.com/stretchr/testify/assert/assertion_forward.go (1)
1131-1163
: LGTM! New assertion methods enhance testing capabilities.The new
NotElementsMatch
andNotElementsMatchf
methods provide useful inverse operations for the existingElementsMatch
methods, allowing explicit testing for non-matching collections.Consider using these new methods when you need to explicitly verify that collections are different, rather than using
assert.False(ElementsMatch(...))
.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
📒 Files selected for processing (17)
go.mod
(1 hunks)vendor/github.com/stretchr/testify/assert/assertion_compare.go
(13 hunks)vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go
(0 hunks)vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go
(0 hunks)vendor/github.com/stretchr/testify/assert/assertion_format.go
(8 hunks)vendor/github.com/stretchr/testify/assert/assertion_forward.go
(11 hunks)vendor/github.com/stretchr/testify/assert/assertion_order.go
(5 hunks)vendor/github.com/stretchr/testify/assert/assertions.go
(26 hunks)vendor/github.com/stretchr/testify/assert/http_assertions.go
(8 hunks)vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go
(1 hunks)vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go
(1 hunks)vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go
(1 hunks)vendor/github.com/stretchr/testify/require/require.go
(111 hunks)vendor/github.com/stretchr/testify/require/require.go.tmpl
(1 hunks)vendor/github.com/stretchr/testify/require/require_forward.go
(11 hunks)vendor/github.com/stretchr/testify/require/requirements.go
(1 hunks)vendor/modules.txt
(1 hunks)
💤 Files with no reviewable changes (2)
- vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go
- vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go
✅ Files skipped from review due to trivial changes (1)
- go.mod
🔇 Additional comments (47)
vendor/modules.txt (2)
58-59
: Confirm Updated Testify Version and Go Minimum VersionThe dependency version for
github.com/stretchr/testify
has been updated to v1.10.0 and the Go version requirement changed fromgo 1.20
togo 1.17
. Please verify that lowering the minimum Go version is intentional and compatible with the rest of the codebase.
61-61
: New YAML Assertion ImportThe new import path
github.com/stretchr/testify/assert/yaml
has been added to support enhanced YAML functionality. Ensure that any relevant tests or documentation are updated accordingly to leverage these new features.vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go (4)
1-10
: LGTM! Well-documented build constraints and package purpose.The build constraints are correctly implemented using both new and old syntax for maximum compatibility. The package documentation clearly explains its purpose, usage, and relationship to the original YAML package.
12-12
: LGTM! Minimal and necessary import.
14-14
: LGTM! Well-defined error with helpful documentation link.The error message is clear and follows Go's error handling best practices by providing a URL for further documentation.
16-18
: LGTM! Clean and purposeful implementation.The function correctly implements the standard YAML Unmarshal signature and fulfills its purpose of always failing with a descriptive error.
vendor/github.com/stretchr/testify/assert/assertion_compare.go (3)
10-13
: LGTM! Good deprecation approach.The deprecation notice and type alias approach maintains backward compatibility while signaling the intent to remove
CompareType
in future versions.
331-337
: LGTM! Improved time comparison logic.The change to use time.Time's built-in comparison methods (
Before
,Equal
) is more idiomatic and potentially more efficient.
393-393
: LGTM! Consistent type updates.The comparison functions have been consistently updated to use the new
compareResult
type while maintaining their behavior.Also applies to: 406-406, 418-418, 431-431, 443-443, 455-455
vendor/github.com/stretchr/testify/assert/assertion_order.go (2)
9-9
: LGTM! Consistent type update.The
isOrdered
function signature has been updated to usecompareResult
while maintaining its behavior.
53-53
: LGTM! Consistent updates across ordering functions.All ordering assertion functions have been consistently updated to use the new
compareResult
type while maintaining their behavior.Also applies to: 62-62, 71-71, 80-80
vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go (1)
1-2
: LGTM! Build tags are correctly configured.The build tags are properly set up to ensure mutual exclusion between different YAML implementations. Both modern (
//go:build
) and legacy (// +build
) syntaxes are included for compatibility.vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go (1)
1-2
: LGTM! Build tags are correctly configured.The build tags are properly set up to ensure mutual exclusion between different YAML implementations. Both modern (
//go:build
) and legacy (// +build
) syntaxes are included for compatibility.vendor/github.com/stretchr/testify/assert/http_assertions.go (4)
15-15
: Improved request creation using http.NoBodyThe change from
nil
tohttp.NoBody
for request bodies is a good improvement. Usinghttp.NoBody
is more explicit and safer, aligning with Go's best practices for HTTP request creation.Also applies to: 119-119
35-35
: Enhanced error reporting with custom messagesThe addition of
msgAndArgs
to allFail
calls is a valuable improvement that:
- Allows custom context in test failure messages
- Maintains consistency across all HTTP assertion functions
- Improves debugging experience
Also applies to: 40-40, 57-57, 62-62, 79-79, 84-84, 101-101, 106-106, 141-141, 161-161
116-118
: Improved URL construction with conditional query parametersGood improvement to only append query parameters when they exist. This makes the URLs cleaner and more readable when no parameters are present.
1-166
:✅ Verification successful
Verify compatibility with the new testify version
Since this is an update from v1.8.4 to v1.10.0, let's verify there are no breaking changes that could affect existing tests.
🌐 Web query:
What are the breaking changes in github.com/stretchr/testify v1.10.0 compared to v1.8.4?
💡 Result:
The key breaking changes between testify v1.8.4 and v1.10.0 include API deprecations and dependency updates:
1️⃣ Deprecated Assertion Methods
assert.HTTPBodyContains
/HTTPBodyNotContains
: A breaking API change introduced in v1.6.x was reverted by v1.x.x (post-v1.8.x), potentially affecting users who relied on older signatures[10].mock.AnythingOfTypeArgument
: Deprecated in favor ofmock.IsType()
[9][10].
2️⃣ Dependency Updates
- Objx dependency upgraded to v0.X.X, addressing security vulnerabilities[2]. This could break projects relying on older objx versions through transitive dependencies[2][4].
3️⃣ Behavioral Changes
assert.Subset
/NotSubset
: Fixed handling of maps missing subset keys (behavioral correction)[1].- YAML dependency made optional via build tags (
yaml
build tag required)[1].
4️⃣ New Features with Potential Impacts
- Added
assert.EventuallyWithT
(customizable timeout logic)[1].- Introduced
assert.NotElementsMatch
(new assertion)[1].- Mock calls now support ordered execution via
InOrder()
[9][10].
Summary Table
Change Type Details Impacted Version Range Deprecated APIs HTTPBodyContains
,AnythingOfTypeArgument
≥v1.X.X Dependency Updates Objx ≥vX.X.X (security fixes) ≥vX.X.X Behavioral Fixes Subset
/NotSubset
map handling≥vX.X.X New Assertions EventuallyWithT
,NotElementsMatch
,NotErrorAs
,PanicAssertionFunc
≥vX.X.X For projects upgrading from v1.X.X, review deprecated method usage and dependency chains involving objx[2][4].
Citations:
- 1: https://github.com/stretchr/testify/releases
- 2: Yaml3.0.0 vulnerability via objx v0.5.0 stretchr/testify#1292
- 3: https://kolaente.dev/vikunja/vikunja/commit/28b1bb824a0a6ce2d8fe73b8584e03bd359738ea
- 4: https://github.com/moov-io/ach/blob/master/CHANGELOG.md
- 5: https://pkg.go.dev/github.com/stretchr/testify/suite
- 6: https://gitlab.com/gitlab-org/terraform-provider-gitlab/-/merge_requests/1756
- 7: https://docs.docker.com/compose/releases/release-notes/
- 8: https://forums.swift.org/t/swift-package-diagnose-api-breaking-changes/54308
- 9: https://pkg.go.dev/github.com/stretchr/testify/mock
- 10: https://gitlab.jonasled.de/jonasled/smtp-gotify/-/merge_requests/4
Compatibility Verified: Testify v1.10.0 HTTP Assertions Are Unchanged
After reviewing the vendor file and comparing against the testify v1.10.0 release notes, we found that the HTTP assertion functions (including
HTTPSuccess
,HTTPRedirect
,HTTPError
,HTTPStatusCode
,HTTPBodyContains
, andHTTPBodyNotContains
) remain compatible with their implementations in v1.8.4. The breaking changes noted in the update primarily address deprecated methods and dependency adjustments (e.g., Objx) that do not affect the HTTP assertion methods in this file.
- The reverted API change for HTTP body assertions ensures no disruption for tests relying on these methods.
- No changes in behavior or signature were detected in the HTTP-related assertions.
- Dependency updates have been handled without impacting these assertions.
vendor/github.com/stretchr/testify/assert/assertions.go (15)
22-24
: Add clarity to the YAML wrapper import.The new wrapper approach is consistent with the rest of the code and helps decouple direct dependency from the underlying YAML library. Just ensure that any advanced YAML features are still supported or tested through the wrapper.
50-52
: Good use of type alias for PanicAssertionFunc.This change enables more flexible usage patterns for panic assertion functions. No major concerns here.
119-124
: Verify array reflection usage.When creating new arrays via
reflect.New(reflect.ArrayOf(...))
, ensure it is compatible with any older Go versions in your build matrix. Otherwise, this approach is valid for sophisticated reflection logic.
169-196
: Refined numeric-conversion checks inObjectsAreEqualValues
.These changes enhance type safety when comparing numeric types by ensuring both convertibility and correct type promotion. Implementation looks solid.
198-202
: Expanding numeric kinds inisNumericType
.Covers all current numeric kinds in Go. If new numeric types appear in future releases, revisiting this function may be necessary.
505-509
: Strict pointer validation inSame
.Ensuring pointer arguments are valid before checking if they point to the same object helps avoid runtime errors. This is a welcome stability improvement.
531-538
: Consistent pointer checks inNotSame
.This logic parallels the
Same
function’s approach, properly verifying pointer arguments before determining if they reference distinct objects.
545-561
: Detailed pointer comparison insamePointers
.Enforcing pointer-type checks first is a good safeguard. The explicit
return false, false
clarifies early exit. Looks well-structured overall.
692-695
: Nil-check integration forreflect.UnsafePointer
.Including
reflect.UnsafePointer
in the nil-check cases extends coverage for advanced pointer usage. No immediate concerns.
799-805
: Improved error messages inLen
.Returning the actual vs. expected lengths provides clear feedback. This matches the library’s user-friendly patterns.
1523-1531
: NaN handling inInEpsilon
.Explicitly failing if any float is NaN prevents ambiguous test outcomes and clarifies the assertion logic.
1545-1564
: Enhanced checks forInEpsilonSlice
.Early returns on nil and non-slice types reduce confusion. This aligns with the library’s thorough approach to type validation.
2021-2035
: Error aggregation inEventuallyWithT
.Collecting errors from the last tick helps diagnose flaky or timing-dependent tests. This is a practical addition for debugging.
2113-2135
: NewNotErrorIs
assertion.Provides a counterpart to
ErrorIs
to confirm an error does not appear in the chain. Straightforward and useful addition.
2154-2171
: NewNotErrorAs
assertion.Complements
ErrorAs
by verifying the absence of a target error type in the chain. Implementation aligns well with existing patterns.vendor/github.com/stretchr/testify/require/require.go.tmpl (1)
1-1
: Replace “assert.” references with “require.” in comments.Switching to “require.” references improves clarity and consistency for the generated require-based assertion functions.
vendor/github.com/stretchr/testify/require/requirements.go (1)
9-9
: Adopt type alias fortHelper
.Using
type tHelper = interface { Helper() }
is a minor syntactic shift with no functional impact. This keeps definitions succinct.vendor/github.com/stretchr/testify/assert/assertion_format.go (5)
107-108
: Documentation improvement for EqualValues functions.The updated comment clarifies that values can be equal when converted to a larger type, which better explains the type conversion behavior.
571-586
: New assertion function: NotElementsMatch.Good addition of the inverse operation for ElementsMatch. The implementation includes clear examples demonstrating the behavior with duplicate elements.
624-631
: New assertion function: NotErrorAs.Good addition of error chain matching functionality. The implementation aligns with Go's error handling patterns.
642-650
: New assertion function: NotImplements.Good addition of interface implementation verification. The implementation helps test negative cases for interface conformance.
696-702
: Documentation improvement for Subset/NotSubset functions.The updated comments clarify that these functions work with both lists and maps, improving API clarity.
Also applies to: 785-790
vendor/github.com/stretchr/testify/require/require_forward.go (4)
1132-1164
: Synchronized NotElementsMatch methods in require package.Good synchronization of the new NotElementsMatch functionality between assert and require packages. The implementation maintains consistency in behavior and documentation.
1238-1254
: Synchronized NotErrorAs methods in require package.Good synchronization of the new NotErrorAs functionality between assert and require packages. The implementation maintains consistency in error handling patterns.
1274-1292
: Synchronized NotImplements methods in require package.Good synchronization of the new NotImplements functionality between assert and require packages. The implementation maintains consistency in interface verification.
1-2
:❓ Verification inconclusive
Verify the version update is safe.
The update from v1.8.4 to v1.10.0 appears safe to apply as it:
- Adds new assertion functions without breaking existing ones
- Improves documentation clarity
- Maintains consistency between assert and require packages
Run the following script to check for any breaking changes in the testify package:
🏁 Script executed:
#!/bin/bash # Description: Check for breaking changes in testify package # Check for removed functions or changed signatures rg -A 1 "^func \([^)]+\) \w+" vendor/github/stretchr/testify/ # Check for changes in existing test files using testify fd -e go -x rg -l "github.com/stretchr/testify"Length of output: 928
Below is an updated review comment. Note that the initial script encountered a “No such file” error due to a directory path mismatch. To ensure full confidence, please verify manually (or re-run the adjusted verification script) that all functions in the require package remain unchanged and that the generated code header is intact.
Ensure safe compatibility for the testify upgrade (v1.8.4 → v1.10.0).
The update is expected to be safe since it only adds new assertion functions and improves documentation, with no removals or modifications to existing functionality. However, the original shell script’s error indicates the need for a manual check on the file paths. In particular:
- Verify that the file
./vendor/github.com/stretchr/testify/require/require_forward.go
exists and contains the correct generated header:// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
- Confirm that no existing function signatures in the require package have been altered.
For additional verification, you can run the following script:
#!/bin/bash # Verify function definitions and generated code header in require_forward.go rg -A 2 "^func " ./vendor/github.com/stretchr/testify/require/require_forward.go rg "^// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT." ./vendor/github.com/stretchr/testify/require/require_forward.goPlease review the verification results manually to ensure consistency across the package.
vendor/github.com/stretchr/testify/assert/assertion_forward.go (1)
189-190
: LGTM! Documentation clarification improves understanding.The updated comment for
EqualValues
now clearly specifies that values can be converted to a larger type for comparison, making the behavior more explicit.vendor/github.com/stretchr/testify/require/require.go (3)
1432-1470
: LGTM! New require methods maintain consistency with assert package.The new
NotElementsMatch
andNotElementsMatchf
methods in the require package provide the same functionality as their assert counterparts but with immediate test failure on assertion failure.
37-39
: LGTM! Example updates improve clarity.The examples have been updated to use
require
instead ofassert
to accurately reflect the package being used.Also applies to: 53-55, 94-95, 109-110
1-10
:❓ Verification inconclusive
Verify compatibility with existing test suites.
The update to testify v1.10.0 adds new assertion methods and improves documentation without breaking changes. However, it's recommended to:
- Run your test suite to verify no issues with the updated package
- Consider adopting the new assertion methods where appropriate
Run the following script to check for any test failures after the update:
🏁 Script executed:
#!/bin/bash # Description: Run all tests to verify compatibility with testify v1.10.0 # Find and run all test files fd -e go -t f "_test" -x go test -v {}Length of output: 3460
Manual Test Verification Required
The update to testify v1.10.0 in the vendor
require
package appears to introduce new assertion methods and documentation improvements without removing or modifying existing functionality. However, the automated test run produced multiple build failures with undefined symbols in various test files (such as inlift_test.go
,groupid_test.go
,parser_test.go
, etc.). It’s not clear whether these errors stem from the testify update or from another issue in the codebase.
- Action Item: Manually verify your test environment to ensure that these build errors are not a side effect of the testify update.
- Recommendation: Re-run your tests focusing on changes involving the
require
package to confirm that your test suite remains compatible.- Next Steps: Investigate the undefined symbols reported in the failing test files to determine if they require fixes unrelated to this update.
This PR contains the following updates:
v1.8.4
->v1.10.0
Release Notes
stretchr/testify (github.com/stretchr/testify)
v1.10.0
Compare Source
What's Changed
Functional Changes
Fixes
Documantation, Build & CI
New Contributors
Full Changelog: stretchr/testify@v1.9.0...v1.10.0
v1.9.0
Compare Source
What's Changed
Called
by @aud10slave in https://github.com/stretchr/testify/pull/631NotImplements
and variants by @hslatman in https://github.com/stretchr/testify/pull/1385New Contributors
Full Changelog: stretchr/testify@v1.8.4...v1.9.0
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.