[Test Improver] test: expand coverage for update command (64% -> ~95%)#657
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
[Test Improver] test: expand coverage for update command (64% -> ~95%)#657danielmeppiel wants to merge 1 commit intomainfrom
danielmeppiel wants to merge 1 commit intomainfrom
Conversation
Add 21 new tests covering previously untested paths in update.py: - Platform helper tests: _is_windows_platform(), _get_update_installer_url(), _get_update_installer_suffix(), _get_manual_update_command() (Unix path) - _get_installer_run_command(): /bin/sh fallback, pwsh fallback, no PowerShell error - Update command logic: dev version (with/without --check), can't fetch latest, already on latest, update available with --check, installer failure (exit 1), requests not available (exit 1), network error (exit 1), temp file cleanup 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 PR — an AI assistant focused on improving test quality for this repository.
Goal and Rationale
The
apm updatecommand had only 3 tests (64% coverage) covering the success-path installer logic. Many important code paths were untested:_is_windows_platform,_get_update_installer_url, etc.)/bin/shfallback on Unix,requestsnot installedThese are real user-facing code paths that can silently fail (e.g., wrong installer URL served to the wrong platform, missing PowerShell erroring without a clear message).
Approach
Added 21 new tests in two new test classes alongside the existing
TestUpdateCommand:TestUpdatePlatformHelpers: Pure unit tests for all platform-detection helper functions. No mocking of subprocess or network — just platform patches.TestUpdateCommandLogic: Integration-style tests viaCliRunnercovering the full command flow for each error/success branch.Coverage Impact
src/apm_cli/commands/update.pyTotal tests: 3790 (main) → 3811 (branch, +21)
Trade-offs
requests.get,subprocess.run, andget_version— standard patterns for CLI command testing in this repo.requestsImportError test usesbuiltins.__import__patching, which is slightly more involved but accurately tests the fallback path.Reproducibility
Test Status
All 3811 tests pass (3790 pre-existing + 21 new).