forked from raystack/guardian
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: same total count when offset and size is applied (#122)
* fix: same total count when offset ans size is applied * Fix: test * fix: commenting test cases * fix: test case * fix: test cases * fix: comments --------- Co-authored-by: utsav14nov <[email protected]>
- Loading branch information
1 parent
4cdfc56
commit 607e725
Showing
4 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,10 +191,52 @@ func (s *AppealRepositoryTestSuite) TestGetByID() { | |
} | ||
|
||
func (s *AppealRepositoryTestSuite) TestGetAppealsTotalCount() { | ||
|
||
dummyAppeals := []*domain.Appeal{ | ||
{ | ||
ResourceID: s.dummyResource.ID, | ||
PolicyID: s.dummyPolicy.ID, | ||
PolicyVersion: s.dummyPolicy.Version, | ||
AccountID: "[email protected]", | ||
AccountType: domain.DefaultAppealAccountType, | ||
Role: "role_test", | ||
Status: domain.AppealStatusApproved, | ||
Permissions: []string{"permission_test"}, | ||
CreatedBy: "[email protected]", | ||
}, | ||
} | ||
|
||
err := s.repository.BulkUpsert(context.Background(), dummyAppeals) | ||
s.Require().NoError(err) | ||
|
||
s.Run("should return 0", func() { | ||
_, actualError := s.repository.GetAppealsTotalCount(context.Background(), &domain.ListAppealsFilter{}) | ||
s.Nil(actualError) | ||
}) | ||
|
||
s.Run("Should always return total count on any size and any offset on success", func() { | ||
testCases := []struct { | ||
filters domain.ListAppealsFilter | ||
}{ | ||
{ | ||
filters: domain.ListAppealsFilter{ | ||
Size: 1, | ||
Offset: 0, | ||
}, | ||
}, | ||
{ | ||
filters: domain.ListAppealsFilter{ | ||
Size: 1, | ||
Offset: 1, | ||
}, | ||
}, | ||
} | ||
for _, tc := range testCases { | ||
total, actualError := s.repository.GetAppealsTotalCount(context.Background(), &tc.filters) | ||
s.NotNil(total) | ||
s.Nil(actualError) | ||
} | ||
}) | ||
} | ||
|
||
func (s *AppealRepositoryTestSuite) TestFind() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters