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

Improve HistoryRecordManager tests #7700

Merged
merged 2 commits into from
Jan 27, 2022
Merged

Conversation

Stypox
Copy link
Member

@Stypox Stypox commented Jan 24, 2022

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

This PR improves the HistoryRecordManager getRelatedSearches tests by shuffling items before inserting them and adding a new getRelatedSearches_emptyQuery_manyDuplicates test.

Fixes the following issue(s)

Nothing, but check out #7553 and #7491 for context

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

@XiangRongLin XiangRongLin added the codequality Improvements to the codebase to improve the code quality label Jan 25, 2022
Comment on lines 102 to 105
// shuffle to make sure the order of items returned by queries depends only on
// SearchHistoryEntry.creationDate, not on the actual insertion time
database.searchHistoryDAO().insertAll(relatedSearches.shuffled())
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a very subjective view, so feel free to ignore it:

I finally figured out, why this stood out to me. It ensures that the ORDER_BY_CREATION_DATE inside the dao is working but does it implicitly in every test instead of getting its own dedicated test. The 2 lines of comments are needed to convey this implicit test. In my personal opinion this should be put into its own test and then the helper method can also be removed as I see 2 lines as an acceptaple duplication

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch. I think order should be enforced in each test, since each test checks that the correct items are returned and in the correct order in many situations. Therefore I'll leave the code as it is and add a comment explaining that shuffling the items is used to verify the ORDER BY works. I pushed, please approve again ;-)

XiangRongLin
XiangRongLin previously approved these changes Jan 26, 2022
@XiangRongLin
Copy link
Collaborator

LGTM

@sonarcloud
Copy link

sonarcloud bot commented Jan 27, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@XiangRongLin XiangRongLin merged commit 466db83 into TeamNewPipe:dev Jan 27, 2022
This was referenced Feb 11, 2022
@Stypox Stypox deleted the history-test branch August 4, 2022 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codequality Improvements to the codebase to improve the code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants