Skip to content

test: move batch 3 tests to public APIs - #993

Open
martintmk wants to merge 4 commits into
mainfrom
martintmk-public-api-tests-batch-3
Open

martintmk wants to merge 4 commits into
mainfrom
martintmk-public-api-tests-batch-3

Conversation

@martintmk

@martintmk martintmk commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

This automated mechanical PR moves tests for bytesbuf_io, cachet, cachet_memory, cachet_service, and cachet_tier to dedicated integration targets by behavior area.

Every existing unit test in these five packages was audited. The change moves 223 tests and retains 60 tests for private details.

Package Original unit tests Moved Retained
bytesbuf_io 44 43 1
cachet 143 99 44
cachet_memory 44 29 15
cachet_service 34 34 0
cachet_tier 18 18 0

The migrated cases use 25 dedicated integration targets. There are no catch-all public_api.rs targets.

Package Target names under tests/
bytesbuf_io read_operations, stream_reads, write_operations, fake_read, fake_write, null_io, pending_io
cachet cache_operations, cache_builders, telemetry, fallback_operations, transformed_storage, entry_expiration, serialization_contracts, refresh, insert_rejection
cachet_memory configuration, eviction_policy, tier_operations
cachet_service requests, extensions, service_adapter
cachet_tier dynamic_storage, errors, mock_storage

Tests use existing public builders, traits, test utilities, frozen clocks, and event handlers. No production API seam was added. One unused test-only accessor was removed.

Each cachet executable initializes tracing. The fallback and refresh targets share their completion handler through conventional mod support discovery. Existing feature and platform conditions remain attached to the migrated cases.

Retained tests have source comments explaining their boundaries:

  • bytesbuf_io retains a private size-planner case with usize::MAX, which cannot use a real public byte buffer.
  • cachet retains private merger state, builder hooks, internal Debug output, exact decode details, private codec fixtures, synthetic telemetry contexts, and refresh bookkeeping.
  • cachet_memory retains backing configuration, private callback conversion and injection, builder interception, and deterministic maintenance that the public cache does not expose.

Refresh assertions inspect queued tasks without driving the runtime, or wait for completion events. The hit-severity assertion selects the cache.hit record itself.

Motivation

Tests through public APIs depend on observable behavior rather than internal structure. Internal refactoring therefore needs fewer test changes.

Dedicated targets group tests by behavior area. Private-path tests remain local when the supported public API cannot expose their inputs or assertions.

Evidence

After the final layout change, default-feature compilation passed:

cargo check -p bytesbuf_io -p cachet -p cachet_memory -p cachet_service -p cachet_tier --tests

All 223 migrated cases passed across the 25 targets, with no failures or ignored tests:

cargo test -p bytesbuf_io --all-features --test read_operations --test stream_reads --test write_operations --test fake_read --test fake_write --test null_io --test pending_io
cargo test -p cachet --all-features --test cache_operations --test cache_builders --test telemetry --test fallback_operations --test transformed_storage --test entry_expiration --test serialization_contracts --test refresh --test insert_rejection
cargo test -p cachet_memory --all-features --test configuration --test eviction_policy --test tier_operations
cargo test -p cachet_service --all-features --test requests --test extensions --test service_adapter
cargo test -p cachet_tier --all-features --test dynamic_storage --test errors --test mock_storage

The final scoped Clippy run passed without suppressions:

cargo clippy -p bytesbuf_io -p cachet -p cachet_memory -p cachet_service -p cachet_tier --tests --all-features --locked -- -D warnings

Formatting used the repository formatter toolchain with package selectors. The layout correction preserves all 223 test attributes. All 283 original unit tests remain accounted for, including the 60 retained private cases.

Full suites, coverage, mutation testing, runtime analysis, and spelling checks were not run locally. CI for the final head is pending.

Merge Danger

The main risk is test coverage drift when private construction becomes public operations. Feature gates and separate integration targets can also change test selection. The all-feature runs exercise every migrated case, but do not prove every feature or platform configuration.

Some assertions now observe public events, operations, or Debug output instead of private fields. CI must still assess coverage and mutation results. This PR does not intentionally change runtime behavior.

Move 223 tests across bytesbuf_io, cachet, cachet_memory, cachet_service, and cachet_tier. Document why 60 private-path tests remain.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 10:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Refresh assertions remain nondeterministic, and the telemetry check can pass without verifying the cache.hit event’s severity.

2 open issues
What changed in this PR

This PR moves tests for byte I/O and cache packages toward public APIs, reducing their dependence on internal implementation details. It retains unit tests where public APIs cannot expose the required state.

Changes:

  • Moves 223 tests into integration targets across five packages.
  • Documents why 60 private-detail tests remain local.
  • Reworks refresh and telemetry checks around public operations and removes an unused test-only accessor.
File Description
crates/​cachet/​src/​wrapper.rs Removes migrated tests and the test-only name accessor.
crates/​cachet/​src/​transform/​tier.rs Retains private adapter checks; removes migrated tests.
crates/​cachet/​src/​transform/​testing.rs Documents the private codec fixture boundary.
crates/​cachet/​src/​telemetry/​seismograph.rs Explains retained event-encoding tests.
crates/​cachet/​src/​telemetry/​cache.rs Removes migrated telemetry tests; documents retained cases.
crates/​cachet/​src/​telemetry/​attributes.rs Removes migrated constant checks.
crates/​cachet/​src/​serialize/​codec.rs Retains private decode checks; removes migrated cases.
crates/​cachet/​src/​refresh.rs Retains bookkeeping tests; removes migrated refresh cases.
crates/​cachet/​src/​fallback.rs Retains private construction checks; removes public-behavior tests.
crates/​cachet/​src/​eviction.rs Explains retained hook tests.
crates/​cachet/​src/​cache.rs Retains merger checks; removes migrated cache tests.
crates/​cachet/​src/​builder/​transform.rs Removes migrated tier-role telemetry test.
crates/​cachet/​src/​builder/​cache.rs Retains private hook and naming checks.
crates/​cachet/​src/​builder/​buildable.rs Removes migrated nested-fallback role test.
crates/​cachet_tier/​tests/​public_api.rs Adds error, shared-state, and mock-failure tests.
crates/​cachet_tier/​src/​testing.rs Removes migrated mock-failure tests.
crates/​cachet_tier/​src/​error.rs Removes migrated error tests.
crates/​cachet_tier/​src/​dynamic.rs Removes migrated shared-state test.
crates/​cachet_service/​tests/​public_api.rs Adds request, adapter, and extension tests.
crates/​cachet_service/​src/​request.rs Removes migrated request and response tests.
crates/​cachet_service/​src/​ext.rs Removes migrated extension-method tests.
crates/​cachet_service/​src/​adapter.rs Removes migrated adapter tests.
crates/​cachet_memory/​tests/​public_api.rs Adds configuration, policy, and cache-operation tests.
crates/​cachet_memory/​src/​tier.rs Retains backing-state and maintenance tests.
crates/​cachet_memory/​src/​policy.rs Retains private policy-conversion checks.
crates/​cachet_memory/​src/​notification.rs Explains retained removal-cause conversion tests.
crates/​cachet_memory/​src/​builder.rs Retains private callback tests; removes migrated cases.
crates/​bytesbuf_io/​tests/​public_api.rs Adds public read, write, stream, and utility tests.
crates/​bytesbuf_io/​src/​write_ext.rs Removes migrated write-extension tests.
crates/​bytesbuf_io/​src/​testing/​pending.rs Removes migrated pending-I/O tests.
crates/​bytesbuf_io/​src/​testing/​null.rs Removes migrated null-I/O tests.
crates/​bytesbuf_io/​src/​testing/​fake_write.rs Removes migrated fake-writer tests.
crates/​bytesbuf_io/​src/​testing/​fake_read.rs Retains the size-limit planner test.
crates/​bytesbuf_io/​src/​read_futures.rs Removes migrated stream-adapter tests.
crates/​bytesbuf_io/​src/​read_ext.rs Removes migrated read-extension tests.

Review effort: Balanced

Comment thread crates/cachet/tests/public_api.rs Resolved
Comment thread crates/cachet/tests/public_api.rs Resolved
Inspect queued refresh tasks without driving the runtime. Check the severity on the cache.hit record rather than unrelated completion logs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 10:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the migration of tests to public APIs.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Mark integration helpers as test code and fix expression and documentation lints without adding suppressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 11:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the migration of tests toward public APIs.

No open issues 🎉

Review effort: Balanced

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (6542ec1) to head (25b51e5).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##            main     #993      +/-   ##
=========================================
  Coverage   99.9%   100.0%              
=========================================
  Files        851       60     -791     
  Lines      74592     4013   -70579     
=========================================
- Hits       74583     4013   -70570     
+ Misses         9        0       -9     
Flag Coverage Δ
linux 100.0% <ø> (ø)
linux-arm 100.0% <ø> (ø)
scheduled ?
windows 100.0% <ø> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

Replace catch-all targets with 25 behavior-specific executables. Preserve all 223 migrated cases, feature gates, per-target tracing initialization, and shared refresh completion support.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues requiring changes.

No open issues 🎉

Review effort: Balanced

@martintmk
martintmk enabled auto-merge (squash) November 19, 2026 16:28
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.

3 participants