Skip to content
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: add unit tests for calculate_piece_range #907

Merged
merged 1 commit into from
Dec 20, 2024
Merged

Conversation

gaius-qi
Copy link
Member

Description

This pull request includes several changes aimed at refactoring the code for calculating piece ranges and improving the test coverage. The main changes involve extracting the calculate_piece_range function into a standalone function and updating the related code to use this new function.

Refactoring and code improvement:

  • dragonfly-client-storage/src/content.rs: Extracted the logic for calculating the target offset and length based on the range into a new function calculate_piece_range. This function is now called in the impl Content block instead of the inline logic. [1] [2] [3]
  • dragonfly-client/src/proxy/cache.rs: Similarly, extracted the logic for calculating the target offset and length into the calculate_piece_range function and updated the impl Cache block to use this function. [1] [2] [3]

Test coverage:

  • Added unit tests for the calculate_piece_range function in both dragonfly-client-storage and dragonfly-client to ensure the correctness of the calculations. [1] [2]

Dependency update:

Minor improvement:

Related Issue

Motivation and Context

Screenshots (if appropriate)

@gaius-qi gaius-qi added the enhancement New feature or request label Dec 20, 2024
@gaius-qi gaius-qi added this to the v1.0.0 milestone Dec 20, 2024
@gaius-qi gaius-qi self-assigned this Dec 20, 2024
@gaius-qi gaius-qi requested a review from a team as a code owner December 20, 2024 04:26
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 97.57576% with 4 lines in your changes missing coverage. Please review.

Project coverage is 34.85%. Comparing base (6ace03a) to head (9bc633a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dragonfly-client/src/proxy/cache.rs 95.29% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #907      +/-   ##
==========================================
+ Coverage   33.63%   34.85%   +1.21%     
==========================================
  Files          60       60              
  Lines        9095     9239     +144     
==========================================
+ Hits         3059     3220     +161     
+ Misses       6036     6019      -17     
Files with missing lines Coverage Δ
dragonfly-client-storage/src/content.rs 38.53% <100.00%> (+35.63%) ⬆️
dragonfly-client/src/proxy/mod.rs 0.00% <ø> (ø)
dragonfly-client/src/proxy/cache.rs 55.47% <95.29%> (+55.47%) ⬆️

Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@gaius-qi gaius-qi merged commit 70b8925 into main Dec 20, 2024
6 checks passed
@gaius-qi gaius-qi deleted the feature/piece branch December 20, 2024 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants