Skip to content

test: add unit tests for least-covered modules - #6

Merged
cedev-1 merged 1 commit into
mainfrom
devin/1784657556-add-unit-tests
Jul 21, 2026
Merged

test: add unit tests for least-covered modules#6
cedev-1 merged 1 commit into
mainfrom
devin/1784657556-add-unit-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Measured per-file line coverage with cargo llvm-cov on cloudreve-api and cloudreve-sync, then added focused unit tests for the pure-logic modules that were least covered. No production code changed (only a one-line indentation fix in drive/utils.rs).

Coverage before → after (lines):

module before after
cloudreve-api/src/boolset/mod.rs 0% 100%
cloudreve-api/src/models/uri.rs 13% 98%
cloudreve-api/src/error.rs 36% 91%
cloudreve-sync/src/uploader/encrypt.rs 0% 100%
cloudreve-sync/src/drive/utils.rs 50% 99%

Workspace line coverage (api + sync) rose ~28% → ~38%. +58 new tests, all inline #[cfg(test)] mod tests blocks matching the repo's existing style.

What the tests exercise:

  • boolset: bit get/set with storage expansion, and/or across differing lengths, base64 round-trip + decode-error fallbacks in from_data.
  • uri (CrUri): prefix validation, component parsing, percent-encoding round-trips (set_path/join/join_raw), parent, SearchParam set↔parse round-trips including the trash restore_uri metadata path and pure_uri filtering.
  • error: ErrorCode::from_code mapping, is_credential_error, and every ApiError::from_response branch (lock conflict, batch w/ aggregated errors, auth→LoginRequired, generic fallback) plus is_token_expired/requires_login.
  • encrypt (EncryptionConfig): metadata validation (bad base64 / wrong key & IV lengths), CTR reversibility, and that chunked encrypt_at_offset (both block-aligned and non-aligned offsets) matches a single full-buffer pass — the property the resumable uploader relies on.
  • drive/utils: local_path_to_cr_uri / remote_path_to_local_relative_path round-trips incl. out-of-root errors, and view_online_url / recycle_bin_url query construction.

Test plan

cargo test -p cloudreve-api -p cloudreve-sync passes (mirrors CI). New tests are deterministic and require no network/DB.

Link to Devin session: https://app.devin.ai/sessions/47a90a862b514e589db48d6ff39765fc
Requested by: @cedev-1

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@cedev-1 cedev-1 self-assigned this Jul 21, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@cedev-1 cedev-1 added the enhancement New feature or request label Jul 21, 2026
@cedev-1
cedev-1 merged commit f902cfc into main Jul 21, 2026
1 check passed
@cedev-1
cedev-1 deleted the devin/1784657556-add-unit-tests branch July 26, 2026 07:49
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.

1 participant