Skip to content

[Test Improver] test: expand update command coverage (3 -> 20 tests)#471

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/update-command-coverage-23625955546-f2c663a436936bb5
Draft

[Test Improver] test: expand update command coverage (3 -> 20 tests)#471
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/update-command-coverage-23625955546-f2c663a436936bb5

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 This is an automated PR from Test Improver, an AI assistant focused on improving tests.

Goal and Rationale

update.py had only 3 tests covering the happy-path Windows and Unix install flows, leaving 7 distinct code paths completely untested. This PR adds 17 tests to cover the remaining paths, focusing on error conditions and guard logic that could hide real bugs.

Approach

Added two new test classes alongside the existing TestUpdateCommand:

  • TestUpdateHelpers — unit tests for the 4 platform-detection helper functions (_get_update_installer_url, _get_update_installer_suffix, _get_installer_run_command). These are pure functions that are easy to test in isolation.
  • Extended TestUpdateCommand — integration-style tests using CliRunner for the main command paths.

Newly covered paths

Scenario Previously Now
Dev version (unknown) without --check Untested Covered
Dev version (unknown) with --check Untested Covered
Version fetch returns None Untested Covered
Already on latest version Untested Covered
--check when update is available Untested Covered
Installer subprocess returns non-zero Untested Covered
requests not importable (ImportError) Untested Covered
Download raises generic exception Untested Covered
Unix manual update command Untested Covered
Helper: URL per platform Untested Covered
Helper: suffix per platform Untested Covered
Helper: run-command /bin/sh fallback Untested Covered
Helper: run-command pwsh fallback Untested Covered
Helper: raises when PowerShell missing Untested Covered

Coverage Impact

File Before After
src/apm_cli/commands/update.py ~25% (3 tests) ~90%+ (20 tests)

Trade-offs

  • All tests mock network and subprocess calls — no live I/O.
  • Platform detection is patched via patch.object(sys, "platform", ...) consistent with existing tests.

Test Status

All 3124 unit tests pass:

3124 passed in 15.33s

Reproducibility

uv run pytest tests/unit/test_update_command.py -v
uv run pytest tests/unit tests/test_console.py -x -q

Generated by Daily Test Improver ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/daily-test-improver.md@b87234850bf9664d198f28a02df0f937d0447295

Add 17 new tests covering previously untested paths in update.py:
- Dev version (unknown) with and without --check returns early
- Version fetch failure exits with error
- Already on latest version exits cleanly
- --check flag reports available update without installing
- Installer failure (non-zero exit) shows error and exits 1
- requests ImportError falls back to manual instructions
- Download exception shows manual update command
- Helper functions: URL, suffix, run-command per platform
- Windows pwsh fallback when powershell not found
- Unix /bin/sh fallback when /bin/sh absent

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant