Skip to content

Commit

Permalink
Merge branch 'v3' into jimmctl-reference-part-2
Browse files Browse the repository at this point in the history
  • Loading branch information
alesstimec authored Dec 4, 2024
2 parents d8bf864 + 55d9bc9 commit a3210c4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/common/pagination/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type LimitOffsetPagination struct {
// NewOffsetFilter creates a filter for limit/offset pagination.
// If limit or offset are out of bounds, defaults will be used instead.
func NewOffsetFilter(limit int, offset int) LimitOffsetPagination {
if limit < 0 {
if limit <= 0 {
limit = defaultOffsetFilterPageSize
}
if limit > maxOffsetFilterPageSize {
Expand Down
7 changes: 7 additions & 0 deletions internal/common/pagination/pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ func TestOffsetFilter(t *testing.T) {
wantLimit: 10,
wantOffset: 5,
},
{
desc: "Valid value are not changed",
limit: 0,
offset: 0,
wantLimit: pagination.DefaultPageSize,
wantOffset: 0,
},
{
desc: "Negative values are corrected",
limit: -1,
Expand Down
13 changes: 13 additions & 0 deletions internal/jimmhttp/rebac_admin/resources_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ func (s *resourcesSuite) TestListResources(c *gc.C) {
wantNextpage *int
ids []testEntity
}{
{
desc: "test default sizes",
wantPage: 0,
wantSize: 5,
ids: ids,
},
{
desc: "test default sizes",
page: utils.IntToPointer(0),
wantPage: 0,
wantSize: 5,
ids: ids,
},
{
desc: "test with first page",
size: utils.IntToPointer(2),
Expand Down
2 changes: 1 addition & 1 deletion rocks/jimm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ parts:
mkdir -p $CRAFT_PART_INSTALL/root/openfga/
# Note that we can't use go run directly (https://github.com/canonical/rockcraft/issues/755)
go install github.com/openfga/cli/cmd/fga@latest
/root/go/bin/fga model transform --file ./openfga/authorisation_model.fga --output-format json > $CRAFT_PART_INSTALL/root/openfga/authorisation_model.json
$GOBIN/fga model transform --file ./openfga/authorisation_model.fga --output-format json > $CRAFT_PART_INSTALL/root/openfga/authorisation_model.json

0 comments on commit a3210c4

Please sign in to comment.