Skip to content

Commit

Permalink
test: fix record iteration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Feb 22, 2025
1 parent 0eab92a commit b3909fe
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions examples/gno.land/p/jeronimoalbi/datastore/record.gno
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ func (rs recordset) Iterate(fn RecordIterFn) (stopped bool) {

offset := rs.query.Offset()
count := rs.query.Size()
if count == 0 {
count = rs.records.Size()
}

return rs.records.IterateByOffset(offset, count, func(_ string, v interface{}) bool {
return fn(v.(Record))
})
Expand All @@ -205,8 +209,12 @@ func (rs recordset) ReverseIterate(fn RecordIterFn) (stopped bool) {
}

offset := rs.query.Offset()
size := rs.query.Size()
return rs.records.ReverseIterateByOffset(offset, size, func(_ string, v interface{}) bool {
count := rs.query.Size()
if count == 0 {
count = rs.records.Size()
}

return rs.records.ReverseIterateByOffset(offset, count, func(_ string, v interface{}) bool {
return fn(v.(Record))
})
}
Expand Down

0 comments on commit b3909fe

Please sign in to comment.