[Test Improver] test: add unit tests for drift-detection helpers (0% -> ~100%)#727
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
Conversation
Add 35 new tests for apm_cli.drift -- pure stateless helpers that drive diff-aware apm install decisions: - detect_ref_change: update_refs mode, new package (None locked), same ref, ref added/removed/changed, hash-based pin changes (11 tests) - detect_orphans: partial install guard, no-lockfile first install, all packages present, single and multiple orphaned packages, empty manifest, None only_packages treated as empty (7 tests) - detect_config_drift: empty inputs, unchanged config, changed config, brand-new entries ignored, multi-entry partial drift, stored superset not flagged (7 tests) - build_download_ref: no lockfile, update_refs mode, ref_changed, locked commit SHA used, 'cached' sentinel not used, proxy host+prefix restored, proxy fallback ref, proxy with existing ref not overridden, non-proxy host diff, key missing from lockfile (10 tests) These helpers are documented as 'easy to test in isolation' yet had no dedicated test file. They are on the critical path of every apm install run -- a bug here can silently prevent re-downloads or incorrectly trigger them. Tests: 3830 -> 3865 (+35) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Test Improver — automated AI assistant
Goal and Rationale
src/apm_cli/drift.pycontains four pure, stateless functions that drive every diff-awareapm installdecision: which packages need re-downloading, which files should be cleaned up, and how to build reproducible download references.The module's own docstring says these helpers are "easy to test in isolation" — yet they had no dedicated test file. A silent bug in any of these functions can cause:
Approach
Tests use minimal in-file dataclass stubs (
_LockedDep,_LockFile) to keep the test file self-contained and dependency-free. No mocking framework or I/O required.detect_ref_changeupdate_refsbypass, new package, same/added/removed/changed ref, hash-based pinsdetect_orphansNonetreated as emptydetect_config_driftbuild_download_refupdate_refs,ref_changed, locked commit SHA,'cached'sentinel skipped, proxy host+prefix restored, proxy fallback ref, key missingCoverage Impact
src/apm_cli/drift.pyTest Status
All 3865 tests pass (3830 baseline + 35 new):
Reproducibility