Skip to content

test: add pagination bounds tests for report entries#1237

Open
LeandroPG19 wants to merge 1 commit into
GyulyVGC:mainfrom
LeandroPG19:test/pagination-bounds
Open

test: add pagination bounds tests for report entries#1237
LeandroPG19 wants to merge 1 commit into
GyulyVGC:mainfrom
LeandroPG19:test/pagination-bounds

Conversation

@LeandroPG19

Copy link
Copy Markdown

Extracts the pagination math from get_searched_entries into a testable paginate<T>() helper and adds 8 tests covering all edge cases.

Before: get_report_entries.rs had zero tests. The pagination formula relied on saturating_sub and unwrap_or_default with 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 Scenario Expected
test_paginate_first_page_full 75 results, page 1 30 items
test_paginate_last_page_partial 75 results, page 3 15 items
test_paginate_page_zero page 0 empty
test_paginate_beyond_last_page 30 results, page 100 empty
test_paginate_empty_data empty input empty
test_paginate_exact_multiple 60 results, page 2 30 items
test_paginate_single_element 1 result, page 1 1 item
test_paginate_page_past_end_with_partial_last 45 results, page 3 empty
test result: ok. 179 passed; 0 failed
``

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
``
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.

1 participant