Skip to content

[coverage-improver] Cover StubAdapter::to_artifact error branch #1635

Description

@TheLarkInn

What branch was uncovered

File: crates/libaipm/src/migrate/adapters/mod.rs
Function: StubAdapter::to_artifact (test-only stub used in migrate::adapters registry ordering/object-safety tests)

The Err(Error::UnsupportedSource(...)) branch of this stub's to_artifact implementation was never exercised — existing tests only called stub.name() and stub.applies_to(...), leaving the file at 88.89% region branch coverage (8/9 hit).

What scenario the new test covers

Added stub_adapter_to_artifact_returns_unsupported_source_error, which constructs a StubAdapter, calls to_artifact with a minimal DiscoveredFeature, and asserts it returns Err(Error::UnsupportedSource(msg)) where msg contains "stub". This directly exercises the previously-uncovered error branch.

Before/after branch coverage

  • adapters/mod.rs branch coverage: 88.89% → 100.00%
  • Overall workspace branch coverage: 90.64% → 90.66%

Test code added

#[test]
fn stub_adapter_to_artifact_returns_unsupported_source_error() {
    // Exercises StubAdapter::to_artifact, which always errs — covers the
    // otherwise-unreachable Err branch of the stub used only for
    // ordering/object-safety tests above.
    let stub = StubAdapter;
    let feat = DiscoveredFeature {
        kind: crate::discovery::FeatureKind::Skill,
        source: crate::discovery::types::DiscoverySource::CLAUDE,
        layout: crate::discovery::Layout::Canonical,
        source_root: std::path::PathBuf::from(".claude"),
        feature_dir: None,
        path: std::path::PathBuf::from(".claude/skills/x/SKILL.md"),
    };
    let result = stub.to_artifact(&feat, &crate::fs::Real);
    assert!(matches!(result, Err(Error::UnsupportedSource(msg)) if msg.contains("stub")));
}

Verification

  • cargo build --workspace
  • cargo test --workspace ✅ (all pass, including the new test)
  • cargo fmt --check
  • cargo clippy --workspace -- -D warnings: pre-existing failures unrelated to this change (manual_is_variant_and lint in resolver/mod.rs and security.rs, confirmed present on main before this change too — already being tracked/fixed by PR fix(clippy): use Result::is_ok_and for Rust 1.98.0 manual_is_variant_and lint #1631)

Generated by Coverage Improver · auto · 118.7 AIC · ⌖ 4.01 AIC · ⊞ 13.1K ·


Note

This was originally intended as a pull request, but PR creation failed. The changes have been pushed to the branch coverage-improver/stub-adapter-to-artifact-error-25f55f1f1013a8f3.

Original error: ERR_API: [2026-08-20T23:37:21.337Z] create pull request in TheLarkInn/aipm failed (attempt 1)

Original error: Resource not accessible by personal access token - https://docs.github.com/rest/pulls/pulls#create-a-pull-request
Retryable: false
Suggestion: This error cannot be resolved by retrying. Please check the error details and fix the underlying issue.

To create the pull request manually:

gh pr create --title "[coverage-improver] Cover StubAdapter::to_artifact error branch" --base main --head coverage-improver/stub-adapter-to-artifact-error-25f55f1f1013a8f3 --repo TheLarkInn/aipm
Show patch preview (47 of 47 lines)
From 2746a884c7623ecd4bcd8cecd539ef4488654b0f Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: 6d3368da0e97be67cb075dba37b9b384df816358
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Thu, 20 Aug 2026 23:35:19 +0000
Subject: [PATCH] test(migrate): cover StubAdapter::to_artifact error branch

Add a unit test exercising the Err path of the test-only StubAdapter
used in migrate::adapters registry ordering/object-safety tests. This
branch was previously unreachable, dropping adapters/mod.rs branch
coverage to 88.89%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 crates/libaipm/src/migrate/adapters/mod.rs | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/crates/libaipm/src/migrate/adapters/mod.rs b/crates/libaipm/src/migrate/adapters/mod.rs
index 322631f..d8dd82c 100644
--- a/crates/libaipm/src/migrate/adapters/mod.rs
+++ b/crates/libaipm/src/migrate/adapters/mod.rs
@@ -142,4 +142,22 @@ mod tests {
         let stub: Box<dyn Adapter> = Box::new(StubAdapter);
         assert_eq!(stub.name(), "stub");
     }
+
+    #[test]
+    fn stub_adapter_to_artifact_returns_unsupported_source_error() {
+        // Exercises StubAdapter::to_artifact, which always errs — covers the
+        // otherwise-unreachable Err branch of the stub used only for
+        // ordering/object-safety tests above.
+        let stub = StubAdapter;
+        let feat = DiscoveredFeature {
+            kind: crate::discovery::FeatureKind::Skill,
+            source: crate::discovery::types::DiscoverySource::CLAUDE,
+            layout: crate::discovery::Layout::Canonical,
+            source_root: std::path::PathBuf::from(".claude"),
+            feature_dir: None,
+            path: std::path::PathBuf::from(".claude/skills/x/SKILL.md"),
+        };
+        let result = stub.to_artifact(&feat, &crate::fs::Real);
+        assert!(matches!(result, Err(Error::UnsupportedSource(msg)) if msg.contains("stub")));
+    }
 }
-- 
2.54
... (truncated)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions