test: add pagination bounds tests for report entries#1237
Open
LeandroPG19 wants to merge 1 commit into
Open
Conversation
Extract paginate() helper from get_searched_entries() and add 8 tests covering edge cases: - first page full (75 results, page 1) - last page partial (75 results, page 3 -> 15 items) - page zero (returns empty) - beyond last page (returns empty) - empty data - exact multiple (60 results, page 2) - single element - page past partial last (45 results, page 3 -> empty) ``` test result: ok. 179 passed; 0 failed ``
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracts the pagination math from
get_searched_entriesinto a testablepaginate<T>()helper and adds 8 tests covering all edge cases.Before:
get_report_entries.rshad zero tests. The pagination formula relied onsaturating_subandunwrap_or_defaultwith no safety net.After:
paginate()is a generic function that takes a slice and a page number, returns the page items + total count. 8 tests cover:test_paginate_first_page_fulltest_paginate_last_page_partialtest_paginate_page_zerotest_paginate_beyond_last_pagetest_paginate_empty_datatest_paginate_exact_multipletest_paginate_single_elementtest_paginate_page_past_end_with_partial_last