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

Fix pagination bug #251

Merged
merged 2 commits into from
Feb 21, 2023
Merged

Fix pagination bug #251

merged 2 commits into from
Feb 21, 2023

Conversation

alexdunnjpl
Copy link
Contributor

@alexdunnjpl alexdunnjpl commented Feb 17, 2023

🗒️ Summary

Fixes a bug in PaginationLidvidBuilder which resulted in incorrect slicing, as well as crashes when provided start parameter was greater than provided limit

⚙️ Test Data and/or Report

Added comprehensive unit tests for PaginationLidvidBuilder.addAll()

♻️ Related Issues

Fixes #240

#250 outstanding


@Test
public void testComplexAddTrimHeadAndTailSpanning() {
PaginationLidvidBuilder pageBuilder = new PaginationLidvidBuilder(new LidvidsContextStub(2, 5));
Copy link
Member

Choose a reason for hiding this comment

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

Try any negatives like LidvidsContextStub(2, -5) or LidvidsContextStub(-2, -5)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seemed defensible (albeit naive) to assume that a passed LidvidsContext would be valid. If that validation isn't already baked into the existing LidvidsContext implementations I'll see what I can do there - might be trivial but I need to verify that start/limit aren't used in any context where negatives are (say) expected, but handled after instantiation.

Plus I'll need to see how to throw in a way that will return a 422, which may be more trouble than is worth doing right this second (but I'll add it to the backlog).

Copy link
Member

Choose a reason for hiding this comment

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

Ok to test raise an exception when limit or start is negative. Ok also to keep 422 error for later. 400 with a dedicated message sounds more than enough to me for now. Thanks

Copy link
Member

@nutjob4life nutjob4life left a comment

Choose a reason for hiding this comment

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

👍

@alexdunnjpl
Copy link
Contributor Author

Merging, and will open a new issue for lower bounds (as it's out of scope for 240) and fix asap.

@alexdunnjpl alexdunnjpl merged commit e08b334 into main Feb 21, 2023
@alexdunnjpl alexdunnjpl deleted the 240-pagination-fix branch February 21, 2023 19:46
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.

Pagination not working as expected with /collections/{identifier}/products
3 participants