[PM-37072] chore: Consolidate MockAuthClient with support for MockRegistrationClientProtocol#2638
Conversation
…istrationClientProtocol
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR consolidates two duplicate Code Review DetailsNo findings. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2638 +/- ##
==========================================
- Coverage 87.35% 86.33% -1.02%
==========================================
Files 1919 2144 +225
Lines 170962 185355 +14393
==========================================
+ Hits 149336 160018 +10682
- Misses 21626 25337 +3711 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| import BitwardenSdkMocks | ||
| import Foundation | ||
|
|
||
| public class MockAuthClient: AuthClientService { |
There was a problem hiding this comment.
🤔 Could we use Sourcery for this? And nonetheless, shouldn't this be named MockAuthClientService?
There was a problem hiding this comment.
We could, yes, this PR was already getting large so I was trying to limit the amount of changes. I have these changes on another branch, so ok if I do this as a follow-up PR?
🎟️ Tracking
PM-37072
📔 Objective
This consolidates
MockAuthClientto BitwardenKit and adds aMockRegistrationClientProtocol.The current
MockAuthClientconforms toAuthClientProtocol. When the SDK builds protocols for services, the protocol methods return the concrete type instead of a protocol type (e.g.AuthClientProtocolreturnsRegistrationClientinstead ofRegistrationClientProtocol). This makes it difficult to use SDK's protocols directly when they return other types which need to be mocked. As a workaround, this adds anAuthClientServiceprotocol which returns aRegistrationClientProtocol, and thenAuthClientcan conform to that. This allows for mockingRegistrationClientwithout too much overhead. TheAuthClientServiceprotocol just needs to be used in place ofAuthClientProtocol.