|
6 | 6 | elemental "github.com/elcengine/elemental/core" |
7 | 7 | "github.com/elcengine/elemental/tests/fixtures/mocks" |
8 | 8 | ts "github.com/elcengine/elemental/tests/fixtures/setup" |
| 9 | + "github.com/google/uuid" |
9 | 10 | "go.mongodb.org/mongo-driver/bson/primitive" |
10 | 11 |
|
11 | 12 | "github.com/samber/lo" |
@@ -74,5 +75,17 @@ func TestCoreReadPaginate(t *testing.T) { |
74 | 75 | So(result.PrevPage, ShouldBeNil) |
75 | 76 | So(result.Docs[0].Name, ShouldEqual, mocks.Ciri.Name) |
76 | 77 | }) |
| 78 | + Convey("First page with filters (No results)", func() { |
| 79 | + result := UserModel.Find(primitive.M{"name": uuid.NewString()}).Paginate(1, 2).Exec().(elemental.PaginateResult[User]) |
| 80 | + So(len(result.Docs), ShouldEqual, 0) |
| 81 | + So(result.TotalPages, ShouldEqual, 0) |
| 82 | + So(result.Page, ShouldEqual, 1) |
| 83 | + So(result.Limit, ShouldEqual, 2) |
| 84 | + So(result.TotalDocs, ShouldEqual, 0) |
| 85 | + So(result.HasPrev, ShouldBeFalse) |
| 86 | + So(result.HasNext, ShouldBeFalse) |
| 87 | + So(result.NextPage, ShouldBeNil) |
| 88 | + So(result.PrevPage, ShouldBeNil) |
| 89 | + }) |
77 | 90 | }) |
78 | 91 | } |
0 commit comments