(t *testing.T)
| 550 | } |
| 551 | |
| 552 | func TestOptionalPaginationParams(t *testing.T) { |
| 553 | tests := []struct { |
| 554 | name string |
| 555 | params map[string]any |
| 556 | expected PaginationParams |
| 557 | expectError bool |
| 558 | }{ |
| 559 | { |
| 560 | name: "no pagination parameters, default values", |
| 561 | params: map[string]any{}, |
| 562 | expected: PaginationParams{ |
| 563 | Page: 1, |
| 564 | PerPage: 30, |
| 565 | }, |
| 566 | expectError: false, |
| 567 | }, |
| 568 | { |
| 569 | name: "page parameter, default perPage", |
| 570 | params: map[string]any{ |
| 571 | "page": float64(2), |
| 572 | }, |
| 573 | expected: PaginationParams{ |
| 574 | Page: 2, |
| 575 | PerPage: 30, |
| 576 | }, |
| 577 | expectError: false, |
| 578 | }, |
| 579 | { |
| 580 | name: "perPage parameter, default page", |
| 581 | params: map[string]any{ |
| 582 | "perPage": float64(50), |
| 583 | }, |
| 584 | expected: PaginationParams{ |
| 585 | Page: 1, |
| 586 | PerPage: 50, |
| 587 | }, |
| 588 | expectError: false, |
| 589 | }, |
| 590 | { |
| 591 | name: "page and perPage parameters", |
| 592 | params: map[string]any{ |
| 593 | "page": float64(2), |
| 594 | "perPage": float64(50), |
| 595 | }, |
| 596 | expected: PaginationParams{ |
| 597 | Page: 2, |
| 598 | PerPage: 50, |
| 599 | }, |
| 600 | expectError: false, |
| 601 | }, |
| 602 | { |
| 603 | name: "invalid page parameter", |
| 604 | params: map[string]any{ |
| 605 | "page": "not-a-number", |
| 606 | }, |
| 607 | expected: PaginationParams{}, |
| 608 | expectError: true, |
| 609 | }, |
nothing calls this directly
no test coverage detected