Skip to content

Improve unit test coverage#23

Merged
MortenGregersen merged 2 commits into
mainfrom
test-coverage-api-key
Jun 9, 2026
Merged

Improve unit test coverage#23
MortenGregersen merged 2 commits into
mainfrom
test-coverage-api-key

Conversation

@MortenGregersen

Copy link
Copy Markdown
Owner

Summary

  • add focused APIKey encoding, decoding, hashing, and keychain conversion tests
  • extend APIKeyController coverage for sorting, lazy loading, deletion, and preview state
  • add behavioral MapError and AppStoreConnectClient delegation tests

Validation

  • swift test
  • swift test --enable-code-coverage

Coverage

  • Project Sources: 65.4%
  • ConnectAccounts: 87.7%
  • APIKey.swift: 100.0%
  • APIKeyController.swift: 93.1%

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands unit test coverage around API key persistence/behavior, error mapping, and client delegation, and wires a new ConnectClient test target into the package/Xcode test configuration.

Changes:

  • Add new focused tests for APIKey encoding/decoding/equality/hashing and keychain conversions, plus additional APIKeyController behaviors (sorting, lazy-load, delete, preview).
  • Add new behavioral tests for mapErrorToConnectError and AppStoreConnectClient request delegation.
  • Register ConnectClientTests in SwiftPM + Xcode scheme/test plan and fix an APIKeyError message formatting issue.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Tests/ConnectCoreTests/MapErrorTests.swift Adds coverage for mapErrorToConnectError mapping behavior (localized, cancelled, service errors, unhandled).
Tests/ConnectClientTests/AppStoreConnectClientTests.swift Adds delegation tests for decoded/empty/paged client requests.
Tests/ConnectAccountsTests/ListAPIKeysTests.swift Adds sorting-by-name coverage for loadAPIKeys().
Tests/ConnectAccountsTests/DeleteAPIKeyTests.swift Adds coverage for lazy-load delete, missing-key behavior, and preview state.
Tests/ConnectAccountsTests/APIKeyTests.swift Adds focused APIKey encoding/decoding/hash/equality and keychain round-trip tests.
Tests/ConnectAccountsTests/APIKeyTestHelpers.swift Introduces shared APIKeyFixture test helper.
Tests/ConnectAccountsTests/AddAPIKeyTests.swift Adds coverage for sorted insertion and lazy-load behavior in addAPIKey.
Testplan.xctestplan Includes the new ConnectClientTests target in the test plan.
Sources/ConnectAccounts/APIKeyError.swift Fixes missing closing parenthesis in an error message.
Package.swift Adds the ConnectClientTests SwiftPM test target.
.swiftpm/xcode/xcshareddata/xcschemes/AppStoreConnectKit-Package.xcscheme Adds ConnectClientTests to the Xcode scheme test action.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Tests/ConnectAccountsTests/DeleteAPIKeyTests.swift Outdated
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.66071% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.11%. Comparing base (c535d2d) to head (0cd682e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Tests/ConnectCoreTests/MapErrorTests.swift 94.28% 2 Missing ⚠️
Sources/ConnectAccounts/APIKeyError.swift 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #23       +/-   ##
===========================================
+ Coverage   73.67%   85.11%   +11.43%     
===========================================
  Files          23       27        +4     
  Lines         946     1169      +223     
===========================================
+ Hits          697      995      +298     
+ Misses        249      174       -75     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@MortenGregersen MortenGregersen changed the title Improve API key unit test coverage Improve unit test coverage Jun 9, 2026
@MortenGregersen
MortenGregersen merged commit e09a836 into main Jun 9, 2026
4 checks passed
@MortenGregersen
MortenGregersen deleted the test-coverage-api-key branch June 9, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants