🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Expands the unit test suite from 14 to 37 tests by adding pure logic tests that run on any platform without requiring winget.
New tests in models.rs (9 tests)
SourceFilter::cycle() — All→Winget→MsStore→All wraparound
SourceFilter::matches() — case-insensitive matching for all variants
SourceFilter Display — correct string representations
Package::is_truncated() — detects … suffix, rejects normal IDs
Operation Display — all four variants (Install with/without version, Uninstall, Upgrade, BatchUpgrade)
New tests in app.rs (14 tests)
Adds a minimal MockBackend (implements WingetBackend with stub returns) to enable testing App methods:
AppMode::cycle() / cycle_back() — full wraparound coverage
AppMode::label() — string labels
App::set_status() — message update
App::spinner() — cycles through all 10 distinct frames
App::apply_filter() — All keeps every package; clears multi-select; clamps selection when list shrinks
App::move_selection() — forward/backward with wraparound; no-op on empty list
App::selected_package() — correct package returned; None on empty list
Test Status
cargo test
test result: ok. 37 passed; 0 failed; 0 ignored (Linux, no winget needed)
cargo clippy -- -D warnings → clean
cargo fmt -- --check → clean
Generated by Repo Assist · ◷
To install this agentic workflow , run
gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch repo-assist/test-pure-logic-2026-03-25-1dabc498499a9ad2.
Click here to create the pull request
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests .
Show patch preview (340 of 340 lines)
From e7b040c6d4ba1a01d210c62d573ee1cfe89474ba Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Wed, 25 Mar 2026 12:36:53 +0000
Subject: [PATCH] test: add unit tests for models, SourceFilter, Operation, and
App state
Extends the test suite from 14 to 37 tests by adding:
- models::tests: SourceFilter cycle/match/display, Package::is_truncated,
and all Operation display variants (9 new tests)
- app::tests: MockBackend, AppMode cycle/label, App apply_filter,
move_selection (wraparound), selected_package, set_status, spinner
(14 new tests)
All tests pass on Linux without requiring winget.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
src/app.rs | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/models.rs | 96 ++++++++++++++++++++++++
2 files changed, 299 insertions(+)
diff --git a/src/app.rs b/src/app.rs
index 3dd2fed..99a32ae 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -432,3 +432,206 @@ impl App {
}
}
}
+
+ #[cfg(test)]
+ mod tests {
+ use std::sync::Arc;
+
+ use async_trait::async_trait;
+
+ use super::*;
+ use crate::backend::WingetBackend;
+ use crate::models::{Package, PackageDetail, Source, SourceFilter};
+
+ struct MockBackend;
+
+ #[async_trait]
+ impl WingetBackend for MockBackend {
+ async fn search(&self, _: &str, _: Option<&str>) -> anyhow::Result<Vec<Package>> {
+ Ok(vec![])
+ }
+ async fn list_installed(&self, _: Option<&str>) -> anyhow::Result<Vec<Package>> {
+ Ok(vec![])
+ }
+ async fn list_upgrades(&self, _: Option<&str>) -> anyhow::Result<Vec<Package>> {
+ Ok(vec![])
+ }
+ async fn show(&self, _: &str) -> anyhow::Result<PackageDetail> {
+ Ok(PackageDetail::default())
+ }
+ async fn install(&self, _: &str, _: Option<&str>) -> anyhow::Result<String> {
+ Ok(String::new())
+ }
+ a
... (truncated)
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Expands the unit test suite from 14 to 37 tests by adding pure logic tests that run on any platform without requiring
winget.New tests in
models.rs(9 tests)SourceFilter::cycle()— All→Winget→MsStore→All wraparoundSourceFilter::matches()— case-insensitive matching for all variantsSourceFilterDisplay— correct string representationsPackage::is_truncated()— detects…suffix, rejects normal IDsOperationDisplay— all four variants (Install with/without version, Uninstall, Upgrade, BatchUpgrade)New tests in
app.rs(14 tests)Adds a minimal
MockBackend(implementsWingetBackendwith stub returns) to enable testingAppmethods:AppMode::cycle()/cycle_back()— full wraparound coverageAppMode::label()— string labelsApp::set_status()— message updateApp::spinner()— cycles through all 10 distinct framesApp::apply_filter()— All keeps every package; clears multi-select; clamps selection when list shrinksApp::move_selection()— forward/backward with wraparound; no-op on empty listApp::selected_package()— correct package returned; None on empty listTest Status
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch
repo-assist/test-pure-logic-2026-03-25-1dabc498499a9ad2.Click here to create the pull request
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests.
Show patch preview (340 of 340 lines)