Skip to content

[Repo Assist] test: add prefer_package and dedupe_packages edge-case tests (231→241)#170

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/test-prefer-package-2026-05-01-3ab83f2af8b0e355
Draft

[Repo Assist] test: add prefer_package and dedupe_packages edge-case tests (231→241)#170
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/test-prefer-package-2026-05-01-3ab83f2af8b0e355

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 1, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

What

Adds 10 new unit tests covering two previously under-tested functions in cli_backend.rs, plus a minor consistency fix in handler.rs.

prefer_package — 7 tests

This function decides which of two duplicate package entries to keep during deduplication. Previously it was only exercised indirectly through dedupe_packages. New direct tests cover every branch:

Test Scenario
prefer_package_newer_version_wins Candidate has higher semver
prefer_package_older_version_loses Candidate has lower semver
prefer_package_equal_versions_more_metadata_wins Tie on version; candidate has source + available
prefer_package_equal_versions_equal_metadata_returns_false Identical metadata → keep existing
prefer_package_unknown_version_loses_to_real "unknown" < any real version
prefer_package_real_version_beats_unknown Real version > "unknown"
prefer_package_equal_versions_one_source_field_wins Source field alone tips the score

dedupe_packages — 3 tests

The existing test only checked version ordering. New tests cover:

Test Scenario
dedupe_packages_different_sources_are_kept_separately Same ID, different sources → both kept
dedupe_packages_keeps_entry_with_most_metadata Equal versions → entry with available_version wins
dedupe_packages_source_comparison_is_case_insensitive winget and Winget treated as the same source

handler.rs — consistency fix

The o (open homepage) action used "Opening {}..." (three ASCII dots) while c (open changelog) used "Opening changelog {}..." (Unicode ellipsis ...). Changed the homepage message to also use ... for visual consistency.

Why

  • prefer_package contains non-trivial branching logic (version comparison + metadata scoring) that wasn't directly tested. These tests document the contract and catch regressions.
  • The dedupe_packages cross-source and metadata-score cases are real production paths exercised when winget list returns the same package from multiple sources.
  • The ellipsis inconsistency was a minor cosmetic roughness.

Test Status

cargo check --all-targets  → clean
cargo fmt -- --check       → clean
cargo clippy -- -D warnings → clean
cargo test                 → 241 passed, 0 failed (was 231)

Generated by Repo Assist · ● 8.4M ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64

Add 7 unit tests for prefer_package covering all branch paths:
- newer version wins
- older version loses
- equal versions: more metadata wins
- equal versions: equal metadata keeps existing
- unknown/empty version loses to real version
- real version beats unknown
- single source field tips the score

Add 3 unit tests for dedupe_packages:
- different sources are kept separately (not merged)
- equal versions: entry with more metadata wins (available_version)
- source comparison is case-insensitive (winget vs Winget)

Also unify the status message ellipsis in handler.rs: use Unicode '…'
for both the 'o' (homepage) and 'c' (changelog) open actions so the
messages are visually consistent.

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.

0 participants