@@ -16,18 +16,15 @@ func TestClientCollection_Paginate(t *testing.T) {
16
16
initDB := mongotest .Connect (t )
17
17
c := NewCollection (initDB (t ).Collection ("test" ))
18
18
19
- // seeds
20
19
seeds := []string {"a" , "b" , "c" }
21
20
_ , _ = c .Client ().InsertMany (ctx , lo .Map (seeds , func (s string , i int ) any {
22
21
return bson.M {"id" : s , "i" : len (seeds ) - i }
23
22
}))
24
23
25
- // nil
26
24
got , goterr := c .Paginate (ctx , nil , nil , nil , nil )
27
25
assert .Nil (t , got )
28
26
assert .NoError (t , goterr )
29
27
30
- // cursor: first
31
28
p := usecasex.CursorPagination {
32
29
First : lo .ToPtr (int64 (1 )),
33
30
}
@@ -44,7 +41,6 @@ func TestClientCollection_Paginate(t *testing.T) {
44
41
assert .NoError (t , goterr )
45
42
assert .Equal (t , []usecasex.Cursor {"a" }, con .Cursors )
46
43
47
- // cursor: first, after
48
44
p = usecasex.CursorPagination {
49
45
First : lo .ToPtr (int64 (1 )),
50
46
After : usecasex .Cursor ("b" ).Ref (),
@@ -62,7 +58,6 @@ func TestClientCollection_Paginate(t *testing.T) {
62
58
assert .NoError (t , goterr )
63
59
assert .Equal (t , []usecasex.Cursor {"c" }, con .Cursors )
64
60
65
- // cursor: last
66
61
p = usecasex.CursorPagination {
67
62
Last : lo .ToPtr (int64 (1 )),
68
63
}
@@ -79,7 +74,6 @@ func TestClientCollection_Paginate(t *testing.T) {
79
74
assert .NoError (t , goterr )
80
75
assert .Equal (t , []usecasex.Cursor {"c" }, con .Cursors )
81
76
82
- // cursor: last, before
83
77
p = usecasex.CursorPagination {
84
78
Last : lo .ToPtr (int64 (1 )),
85
79
Before : usecasex .Cursor ("b" ).Ref (),
@@ -97,7 +91,6 @@ func TestClientCollection_Paginate(t *testing.T) {
97
91
assert .NoError (t , goterr )
98
92
assert .Equal (t , []usecasex.Cursor {"a" }, con .Cursors )
99
93
100
- // cursor: offset
101
94
op := usecasex.OffsetPagination {
102
95
Offset : int64 (1 ),
103
96
Limit : int64 (2 ),
@@ -115,7 +108,6 @@ func TestClientCollection_Paginate(t *testing.T) {
115
108
assert .NoError (t , goterr )
116
109
assert .Equal (t , []usecasex.Cursor {"b" , "c" }, con .Cursors )
117
110
118
- // cursor: offset, sort
119
111
op = usecasex.OffsetPagination {
120
112
Offset : int64 (0 ),
121
113
Limit : int64 (0 ),
@@ -141,18 +133,15 @@ func TestClientCollection_PaginateAggregation(t *testing.T) {
141
133
initDB := mongotest .Connect (t )
142
134
c := NewCollection (initDB (t ).Collection ("test" ))
143
135
144
- // seeds
145
136
seeds := []string {"a" , "b" , "c" }
146
137
_ , _ = c .Client ().InsertMany (ctx , lo .Map (seeds , func (s string , i int ) any {
147
138
return bson.M {"id" : s , "i" : len (seeds ) - i }
148
139
}))
149
140
150
- // nil
151
141
got , goterr := c .PaginateAggregation (ctx , nil , nil , nil , nil )
152
142
assert .Nil (t , got )
153
143
assert .NoError (t , goterr )
154
144
155
- // cursor: first
156
145
p := usecasex.CursorPagination {
157
146
First : lo .ToPtr (int64 (1 )),
158
147
}
@@ -169,7 +158,6 @@ func TestClientCollection_PaginateAggregation(t *testing.T) {
169
158
assert .NoError (t , goterr )
170
159
assert .Equal (t , []usecasex.Cursor {"a" }, con .Cursors )
171
160
172
- // cursor: first, after
173
161
p = usecasex.CursorPagination {
174
162
First : lo .ToPtr (int64 (1 )),
175
163
After : usecasex .Cursor ("b" ).Ref (),
@@ -187,7 +175,6 @@ func TestClientCollection_PaginateAggregation(t *testing.T) {
187
175
assert .NoError (t , goterr )
188
176
assert .Equal (t , []usecasex.Cursor {"c" }, con .Cursors )
189
177
190
- // cursor: last
191
178
p = usecasex.CursorPagination {
192
179
Last : lo .ToPtr (int64 (1 )),
193
180
}
@@ -204,7 +191,6 @@ func TestClientCollection_PaginateAggregation(t *testing.T) {
204
191
assert .NoError (t , goterr )
205
192
assert .Equal (t , []usecasex.Cursor {"c" }, con .Cursors )
206
193
207
- // cursor: last, before
208
194
p = usecasex.CursorPagination {
209
195
Last : lo .ToPtr (int64 (1 )),
210
196
Before : usecasex .Cursor ("b" ).Ref (),
@@ -222,7 +208,6 @@ func TestClientCollection_PaginateAggregation(t *testing.T) {
222
208
assert .NoError (t , goterr )
223
209
assert .Equal (t , []usecasex.Cursor {"a" }, con .Cursors )
224
210
225
- // cursor: offset
226
211
op := usecasex.OffsetPagination {
227
212
Offset : int64 (1 ),
228
213
Limit : int64 (2 ),
@@ -240,7 +225,6 @@ func TestClientCollection_PaginateAggregation(t *testing.T) {
240
225
assert .NoError (t , goterr )
241
226
assert .Equal (t , []usecasex.Cursor {"b" , "c" }, con .Cursors )
242
227
243
- // cursor: offset, sort
244
228
op = usecasex.OffsetPagination {
245
229
Offset : int64 (0 ),
246
230
Limit : int64 (0 ),
@@ -343,7 +327,6 @@ func TestClientCollection_DetailedPagination(t *testing.T) {
343
327
initDB := mongotest .Connect (t )
344
328
c := NewCollection (initDB (t ).Collection ("test" ))
345
329
346
- // Seed data
347
330
seeds := []struct {
348
331
id string
349
332
updatedAt int64
0 commit comments