Skip to content

Conversation

@julio-lopez
Copy link
Collaborator

This is to better compute cache storage utilization.

@julio-lopez julio-lopez requested a review from Copilot June 19, 2025 02:03
Copy link

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 improves the computation of block-aligned sizes for cache storage utilization by updating the core logic and adding comprehensive tests.

  • Implements the GetBlockAlignedSize function with overflow and parameter validation
  • Adds extensive tests covering both valid inputs and error cases

Reviewed Changes

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

File Description
internal/stat/blocksize.go Adds the block-aligned size calculation with parameter checks
internal/stat/blocksize_test.go Provides thorough test cases for valid and error scenarios

}

if size < 0 {
return -1, errors.Wrap(errInvalidParameter, "blockSizeBytes must be positive")
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

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

The error message for a negative size misrepresents the error by stating 'blockSizeBytes must be positive'. Consider updating it to 'size must be non-negative' to accurately reflect the invalid input.

Suggested change
return -1, errors.Wrap(errInvalidParameter, "blockSizeBytes must be positive")
return -1, errors.Wrap(errInvalidParameter, "size must be non-negative")

Copilot uses AI. Check for mistakes.
}

for _, tc := range cases {
t.Run("", func(t *testing.T) {
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

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

Using an empty string for subtest names makes it harder to identify failing cases. Consider including descriptive names that reflect the test case parameters.

Suggested change
t.Run("", func(t *testing.T) {
t.Run(fmt.Sprintf("blockSize=%d, size=%d", tc.blockSize, tc.size), func(t *testing.T) {

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.43%. Comparing base (cb455c6) to head (9647619).
Report is 577 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4679      +/-   ##
==========================================
+ Coverage   75.86%   76.43%   +0.56%     
==========================================
  Files         470      530      +60     
  Lines       37301    40171    +2870     
==========================================
+ Hits        28299    30705    +2406     
- Misses       7071     7451     +380     
- Partials     1931     2015      +84     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant