-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
test(orm) :add test case for bytes.go #22878
Conversation
📝 WalkthroughWalkthroughThe pull request introduces a comprehensive test suite for Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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
Documentation and Community
|
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 (2)
orm/encoding/ormfield/bytes_test.go (2)
3-10
: Reorder imports according to project conventions.The imports should follow the project's standard ordering:
- Standard library
- Default external
cosmossdk.io
github.com/cosmos
import ( "bytes" "testing" - "cosmossdk.io/orm/encoding/ormfield" "github.com/stretchr/testify/assert" "google.golang.org/protobuf/reflect/protoreflect" + "cosmossdk.io/orm/encoding/ormfield" )🧰 Tools
🪛 golangci-lint (1.62.2)
7-7: File is not
gci
-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order(gci)
9-9: File is not
gci
-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order(gci)
21-60
: Consider adding more test cases for BytesCodec.While the current test coverage is good, consider adding these test cases for completeness:
- Empty byte arrays
- Large byte arrays (similar to
TestNonTerminalBytesCodecHandlesLargeInput
)- Error scenarios
Would you like me to help generate these additional test cases?
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
orm/encoding/ormfield/bytes_test.go
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
orm/encoding/ormfield/bytes_test.go (2)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern **/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
🪛 golangci-lint (1.62.2)
orm/encoding/ormfield/bytes_test.go
7-7: File is not gci
-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order
(gci)
9-9: File is not gci
-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order
(gci)
🔇 Additional comments (2)
orm/encoding/ormfield/bytes_test.go (2)
12-19
: LGTM! Clean mock implementation.
The MockReader implementation is well-structured and appropriately scoped for the test requirements.
62-137
: LGTM! Comprehensive test coverage for NonTerminalBytesCodec.
The test suite is well-structured with good coverage of:
- Basic encoding/decoding
- Buffer size computation
- Comparison operations
- Edge cases (empty arrays)
- Stress testing (300-byte arrays)
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.
Hey! If you wish to add this test, please add it in codec_test.go
, matching the style of the other tests.
*bytes.Reader | ||
} | ||
|
||
func NewMockReader(data []byte) *MockReader { |
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.
Why this new definition and type just to avoid typing bytes.NewReader? You simply could write
var newMockReader = bytes.NewReader
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.
ok, i will check it
assert.Equal(t, []byte("hello"), buffer.Bytes()) | ||
|
||
// Decode | ||
decoded, err := codec.Decode(NewMockReader(buffer.Bytes())) |
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.
You could hav passed in buffer directly.
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit