Skip to content

Conversation

@Ashwinn11
Copy link
Contributor

fixes #246
-Added unit testing to the search package

@Ashwinn11 Ashwinn11 requested a review from a team as a code owner May 23, 2024 08:04
int pageSize = 10;
Sort sort = Sort.by("id");

Page<Person> expectedPage = new PageImpl<>(Collections.emptyList(), PageRequest.of(page, pageSize, sort), 0);
Copy link
Member

Choose a reason for hiding this comment

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

Either this test should return results or the test should be renamed to indicate it doesn't return results when no match is found (a valid test case) and then a test should be added that handles results being found. As it is now, this test is a little misleading

@lazyguru
Copy link
Member

lazyguru commented May 23, 2024

@Ashwinn11 thank you for contributing. I added one comment to the review but I would also like to call out that (IMO) this should not close #246 when merged (if merged as-is) since it only adds coverage for 2 methods and there are 5 methods in the class. Yes, it technically meets the requirement of "Add unit tests to Search package" but I believe the intent of the issue was to try to cover as much of the class as possible with at least "happy path" tests (I don't expect 100% coverage)

@Pdzly
Copy link
Member

Pdzly commented May 25, 2024

Great job! Anything else than what @lazyguru said looks fine to me! 👍

@Ashwinn11
Copy link
Contributor Author

Hi @lazyguru ,Thank you for your feedback and suggestions . I have made the following updates to the test class based on your comments:

Renamed the Test Method:

  1. Renamed testSearchPostByUrl to testSearchPostByUrlReturnsEmptyWhenNoCrossPostsFound to clarify that it tests the case where no cross-posts are found.

2)Added a New Test for When Results Are Found:

Added a new test method testSearchPostByUrlWithCrossPostsReturnsResults to handle the case when cross-posts are found and results are returned.

Copy link
Member

@lazyguru lazyguru left a comment

Choose a reason for hiding this comment

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

This is a good start that we can improve on in future PRs. Thank you for this as we had no coverage at all before.

@lazyguru lazyguru requested a review from a team as a code owner May 31, 2024 01:32
@lazyguru lazyguru merged commit 3d7af6a into sublinks:main May 31, 2024
@Ashwinn11 Ashwinn11 deleted the search-unit-tests branch May 31, 2024 02:37
@jgrim
Copy link
Member

jgrim commented May 31, 2024

This is a good start that we can improve on in future PRs. Thank you for this as we had no coverage at all before.

If we need more work a new ticket needs created to finish the work. I don't want it to get lost.

@lazyguru
Copy link
Member

If we need more work a new ticket needs created to finish the work. I don't want it to get lost.

Yup, I got distracted after merging and making that comment so never created the follow-up ticket. Will do that now

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.

Add unit tests to Search package

4 participants