Let WalkAll use coredata collection slice types
WalkAll now accepts loaders and callbacks typed as S ~[]T so exports can use AuditLogEntries and SCIMEvents directly. Pass the trimmed page slice to walk, not the over-fetched loader result. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
@@ -212,3 +212,29 @@ func TestWalkAllHasNoPageCap(t *testing.T) {
|
||||
assert.Equal(t, loadAllValues(store), loadAllValues(got))
|
||||
assert.Greater(t, fetchs, MaxLoadAllPages)
|
||||
}
|
||||
|
||||
type loadAllItems []*loadAllItem
|
||||
|
||||
func TestWalkAllNamedSliceType(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
store := newLoadAllStore(MaxCursorSize + 1)
|
||||
|
||||
var got loadAllItems
|
||||
|
||||
err := WalkAll(
|
||||
context.Background(),
|
||||
ascOrderBy(),
|
||||
func(_ context.Context, cursor *Cursor[testOrderField]) (loadAllItems, error) {
|
||||
return loadAllItems(keysetPage(store, cursor)), nil
|
||||
},
|
||||
func(rows loadAllItems) error {
|
||||
got = append(got, rows...)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Len(t, got, len(store))
|
||||
assert.Equal(t, loadAllValues(store), loadAllValues(got))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user