-
Notifications
You must be signed in to change notification settings - Fork 933
Add comprehensive tests for AuthenticatorRepositoryImpl #6424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6424 +/- ##
==========================================
+ Coverage 84.94% 85.88% +0.94%
==========================================
Files 982 775 -207
Lines 59263 56164 -3099
Branches 8231 8130 -101
==========================================
- Hits 50340 48236 -2104
+ Misses 6066 5097 -969
+ Partials 2857 2831 -26 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Claude finished @SaintPatrck's task in 1m 26s —— View job Code Review SummaryOverall Assessment: 👍 Good test coverage additions with a few items to address from existing review comments. Changes OverviewThis PR adds comprehensive test coverage for
The Review Feedback✅ Strengths
|
| authenticatorRepository.ciphersStateFlow.test { | ||
| assertEquals( | ||
| DataState.Loading, | ||
| DataState.Loaded(emptyList<AuthenticatorItemEntity>()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't thew initial state be Loading?
| private val mockAuthenticatorDiskSource = mockk<AuthenticatorDiskSource> { | ||
| every { getItems() } returns mutableItemsFlow | ||
| coEvery { saveItem(*anyVararg()) } just runs | ||
| coEvery { deleteItem(any()) } just runs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was wrong with the fake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📓 Hm. The fake needed a few tweaks that Claude couldn't figure out, so it fell back to mocking like we do with VaultDiskSource in a few places. That's also why it changed the initial state test. I think we can prevent this from happening again with a few rules.
Expands existing test coverage to include: - getItemStateFlow testing - getLocalVerificationCodesFlow testing - createItem/addItems/hardDeleteItem operations - exportVaultData JSON and CSV formats - importVaultData with various failure scenarios Follows testing-android-code skill patterns with proper StateFlow testing, FakeDispatcherManager usage, and Uri static mocking. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
489f4ff to
643792c
Compare
082f232 to
e36cda8
Compare
e36cda8 to
0066df9
Compare
| fun `getItemStateFlow should emit Loaded with null for non-existent item`() = runTest { | ||
| authenticatorRepository.getItemStateFlow("any-id").test { | ||
| val loadedState = awaitItem() as DataState.Loaded | ||
| assertNull(loadedState.data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just assert the whole state?
assertEquals(
DataState.Loaded(data = null),
awaitItem(),
)|
|
||
| authenticatorRepository.getItemStateFlow("invalid-id").test { | ||
| val loadedState = awaitItem() as DataState.Loaded | ||
| assertNull(loadedState.data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here

🎟️ Tracking
Test coverage improvements for critical authenticator repository functionality.
📔 Objective
This PR enhances test coverage for
AuthenticatorRepositoryImpl, a critical component responsible for managing authenticator data persistence and retrieval in the Authenticator application.Changes:
AuthenticatorRepositoryImplFakeAuthenticatorDiskSourceThe repository layer serves as the primary data access abstraction for authenticator items. These tests ensure data integrity, proper Flow behavior, and correct error propagation throughout the data layer.
📸 Screenshots
N/A - Test-only changes
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes🤖 Generated with Claude Code