Skip to content
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

Update OfflineFirstTopicsRepositoryTest.kt #1798

Merged
merged 4 commits into from
Jan 7, 2025
Merged

Conversation

eyhgpt
Copy link
Contributor

@eyhgpt eyhgpt commented Jan 7, 2025

Improve the unit test to perform meaningful comparisons instead of simply comparing two empty lists.

In the unit test function offlineFirstTopicsRepository_topics_stream_is_backed_by_topics_dao()

Both topicDao.getTopicEntities().first().map(TopicEntity::asExternalModel) and subject.getTopics().first() return an empty list. This is because subject.syncWith(synchronizer) is not called beforehand.

This unit test doesn't seem meaningful by just comparing two empty lists.

This PR adds a subject.syncWith(synchronizer) call before retrieving the topic entities, so that lists with actual elements can be compared, to prove that offlineFirstTopicsRepository.getTopics() is based by topicDao.getTopicEntities().

Improve the unit test to do meaning comparisons instead of just comparing two empty lists.
dturner and others added 3 commits January 7, 2025 12:42
…/core/data/repository/OfflineFirstTopicsRepositoryTest.kt
…/core/data/repository/OfflineFirstTopicsRepositoryTest.kt
@dturner dturner merged commit c6588b0 into android:main Jan 7, 2025
5 checks passed
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