-
Notifications
You must be signed in to change notification settings - Fork 4k
kv: add comprehensive tests for Batch operations #151962
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
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
c87ff87
to
cfab05a
Compare
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 adds comprehensive unit tests for the kv.Batch type to improve test coverage of batch operations. The tests cover all major batch functionality including basic operations (Get, Put, Scan, Delete), conditional operations, bulk operations, error handling, and batch validation.
Key changes:
- Adds 492 lines of comprehensive unit tests for the Batch type
- Tests cover Get, Put, CPut, Inc, Scan, Delete, and bulk operations
- Includes tests for error handling, buffer management, and raw vs non-raw batch mixing
- Updates BUILD.bazel to include the new test file
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
pkg/kv/batch_test.go | New comprehensive test file covering all Batch operations, error handling, and edge cases |
pkg/kv/BUILD.bazel | Adds batch_test.go to the test sources list |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
} | ||
|
||
func (m *mockBulkSourceIterator) Next() (roachpb.Key, []byte) { | ||
m.index++ |
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.
The Next() method doesn't check bounds and will panic if called beyond the data length. Add bounds checking: if m.index >= len(m.data) { return nil, nil }
or similar error handling.
m.index++ | |
m.index++ | |
if m.index >= len(m.data) { | |
return nil, nil | |
} |
Copilot uses AI. Check for mistakes.
} | ||
|
||
func (m *mockValueBulkSourceIterator) Next() (roachpb.Key, roachpb.Value) { | ||
m.index++ |
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.
The Next() method doesn't check bounds and will panic if called beyond the data length. Add bounds checking: if m.index >= len(m.data) { return nil, roachpb.Value{} }
or similar error handling.
m.index++ | |
m.index++ | |
if m.index >= len(m.data) { | |
return nil, roachpb.Value{} | |
} |
Copilot uses AI. Check for mistakes.
This commit adds extensive unit tests for the kv.Batch type, covering all major operations including Get, Put, Scan, Delete, conditional operations, bulk operations, and admin methods. Tests also cover error handling, buffer management, and raw vs non-raw batch mixing. Release notes: None Epic: None
cfab05a
to
26d13e1
Compare
This commit adds extensive unit tests for the kv.Batch type, covering all major operations including Get, Put, Scan, Delete, conditional operations, bulk operations, and admin methods. Tests also cover error handling, buffer management, and raw vs non-raw batch mixing.
Release notes: None
Epic: None