Skip to content

Commit

Permalink
Added pagination tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jsimnz committed Nov 12, 2024
1 parent dbc4697 commit 542ab35
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions x/bulletin/keeper/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper_test
import (
"testing"

"github.com/cosmos/cosmos-sdk/types/query"
"github.com/stretchr/testify/require"

keepertest "github.com/sourcenetwork/sourcehub/testutil/keeper"
Expand Down Expand Up @@ -110,4 +111,26 @@ func TestParamsQueryIterateGlob(t *testing.T) {
Payload: []byte("val3"),
},
}, resp5.Posts)

// pagination
resp6, err := keeper.IterateGlob(ctx, &types.QueryIterateGlobRequest{
Namespace: "test1",
Glob: "*",
Pagination: &query.PageRequest{
Limit: 3,
},
})
require.NoError(t, err)
require.Equal(t, posts[:3], resp6.Posts)

// continuation pagination
resp7, err := keeper.IterateGlob(ctx, &types.QueryIterateGlobRequest{
Namespace: "test1",
Glob: "*",
Pagination: &query.PageRequest{
Key: resp6.Pagination.NextKey,
},
})
require.NoError(t, err)
require.Equal(t, posts[3:], resp7.Posts)
}

0 comments on commit 542ab35

Please sign in to comment.