Skip to content
This repository was archived by the owner on Mar 11, 2026. It is now read-only.

Commit 027e181

Browse files
Merge pull request #2 from mutantkeyboard/develop
- Fix tests - Fix MD issues - Better coverage
2 parents 2af4197 + 8ded1c0 commit 027e181

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ app.Use(spindle.New(spindle.Config{
8787
## Config
8888

8989
| Property | Type | Description | Default |
90-
|----------|------|-------------|---------|
90+
| -------- | ---- | ----------- | ------- |
9191
| Next | `func(c fiber.Ctx) bool` | Skip middleware when returns true | `nil` |
9292
| PageKey | `string` | Query key for page number | `"page"` |
9393
| DefaultPage | `int` | Default page number | `1` |

paginate_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,32 @@ func Test_PaginateFromContextWithoutNew(t *testing.T) {
408408
}
409409
}
410410

411+
func Test_PaginateNextSkip(t *testing.T) {
412+
t.Parallel()
413+
app := fiber.New()
414+
app.Use(New(Config{
415+
Next: func(c fiber.Ctx) bool {
416+
return true
417+
},
418+
}))
419+
420+
app.Get("/", func(c fiber.Ctx) error {
421+
_, ok := FromContext(c)
422+
if !ok {
423+
return fiber.ErrBadRequest
424+
}
425+
return c.JSON(nil)
426+
})
427+
428+
resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", nil))
429+
if err != nil {
430+
t.Fatal(err)
431+
}
432+
if resp.StatusCode != fiber.StatusBadRequest {
433+
t.Errorf("status = %d, want %d (middleware should be skipped)", resp.StatusCode, fiber.StatusBadRequest)
434+
}
435+
}
436+
411437
func Test_PaginateEdgeCases(t *testing.T) {
412438
t.Parallel()
413439
app := fiber.New()
@@ -434,6 +460,7 @@ func Test_PaginateEdgeCases(t *testing.T) {
434460
{"Page zero", "/?page=0", 1, 10},
435461
{"Negative limit", "/?limit=-10", 1, 10},
436462
{"Limit zero", "/?limit=0", 1, 10},
463+
{"Limit exceeds max", "/?limit=200", 1, MaxLimit},
437464
}
438465

439466
for _, tc := range testCases {

0 commit comments

Comments
 (0)