refactor(recipe): drop Cached*CountForTesting helpers (#1079)#1099
Conversation
Deletes the two count-based test inspection helpers from pkg/recipe's exported surface. They were convention-only test hooks (the _ForTesting suffix is not enforced) and the only call site (TestClient_NoCacheGrowthAcrossManyCloseCycles) was a baseline-diff assertion that conflated this test's cache growth with sibling tests'. The moved test now lives in the internal aicr test package where it can read Client.dp directly. It captures each iteration's DataProvider before Close and asserts Contains(dp) == false per iteration — a strictly stronger, sibling-test-independent signal than the previous cumulative count delta. The surviving Contains*ForTesting helpers remain exported (per-provider scope, no global cache visibility) and are documented for the same narrow purpose. Refs #1079
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThis PR removes count-based test helpers ( Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Coverage Report ✅
Coverage BadgeMerging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. |
Summary
Removes the two
_ForTestingcount-based cache inspection helpers frompkg/recipe's exported surface and moves the only consumer into the internalaicrtest package where it can use the per-DataProviderContainshelpers instead.Motivation / Context
pkg/recipeis marked Public (evolving) indocs/integrator/public-api.md. The_ForTestingsuffix onCachedStoreCountForTestingandCachedRegistryCountForTestingis convention-only; nothing prevents production callers from using them. The count helpers had a known limitation already documented in the source: their result is global across all DataProviders, so any parallel sibling test perturbs the baseline. Per-providerContains*ForTestinghelpers are scoped correctly and the existing test inaicr_internal_test.goalready prefers them.Fixes: #1079
Related: #1076 (epic), #1072 (PR that introduced the helpers)
Type of Change
Component(s) Affected
pkg/recipe)aicr_test.go,aicr_internal_test.go)Implementation Notes
CachedStoreCountForTesting(pkg/recipe/metadata_store.go) andCachedRegistryCountForTesting(pkg/recipe/components.go).TestClient_NoCacheGrowthAcrossManyCloseCyclesfromaicr_test.go(externalaicr_testpackage) intoaicr_internal_test.go(internalaicrpackage) so it can read the unexportedClient.dpfield directly.Count(before) → 50 cycles → Count(after) == before, the test now capturesdp := c.dpbeforeClose()(which zeros the field) and assertsrecipe.CachedStoreContainsForTesting(dp) == falseper iteration. Strictly stronger signal — fails on iteration 1 if eviction is broken, and per-provider scoping is robust to parallel sibling tests.*RecipeResultis non-nil per iteration (resolver contract).Contains*ForTestinghelpers remain exported but their docstrings were tightened to drop references to the deleted count helpers.The remaining
Contains*ForTestingexports are still convention-only test hooks; fully eliminating them is intentionally deferred (a follow-up could move them behind a build tag or relocate them to an internal subpackage). This PR halves the surface today with no production code changes.Testing
make qualify # passes-race:TestClient_NoCacheGrowthAcrossManyCloseCycles,TestClient_CloseDrainsInflightResolve,TestClient_NoCachePopulationAfterClose.pkg/recipe: 90.8% → 91.3% (+0.5%, deleted uncovered exported helpers)github.com/NVIDIA/aicr: 63.3% → 63.3%Risk Assessment
Rollout notes: N/A — external consumers cannot have been using these correctly (the suffix advertises test-only intent). If anyone was, they get a clear compile-time error and can switch to
Contains*ForTesting.Checklist
make testwith-race)make lint)git commit -S)