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.
- Loading branch information
Lifosmin Simon
authored and
Lifosmin Simon
committed
Aug 30, 2023
1 parent
79b1e6c
commit dd33abf
Showing
4 changed files
with
65 additions
and
11 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 |
---|---|---|
|
@@ -130,15 +130,36 @@ func (s *AppealRepositoryTestSuite) TestGetByID() { | |
}) | ||
|
||
s.Run("should run query based on filters", func() { | ||
dummyAppeal := &domain.Appeal{ | ||
ResourceID: s.dummyResource.ID, | ||
PolicyID: s.dummyPolicy.ID, | ||
PolicyVersion: s.dummyPolicy.Version, | ||
AccountID: "[email protected]", | ||
AccountType: domain.DefaultAppealAccountType, | ||
Role: "role_test", | ||
Permissions: []string{"permission_test"}, | ||
CreatedBy: "[email protected]", | ||
timeNowPlusAnHour := time.Now().Add(time.Hour) | ||
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]", | ||
Options: &domain.AppealOptions{ | ||
ExpirationDate: &time.Time{}, | ||
}, | ||
}, | ||
{ | ||
ResourceID: s.dummyResource.ID, | ||
PolicyID: s.dummyPolicy.ID, | ||
PolicyVersion: s.dummyPolicy.Version, | ||
AccountID: "[email protected]", | ||
AccountType: domain.DefaultAppealAccountType, | ||
Status: domain.AppealStatusCanceled, | ||
Role: "role_test", | ||
Permissions: []string{"permission_test_2"}, | ||
CreatedBy: "[email protected]", | ||
Options: &domain.AppealOptions{ | ||
ExpirationDate: &timeNowPlusAnHour, | ||
}, | ||
}, | ||
} | ||
testCases := []struct { | ||
filters *domain.ListAppealsFilter | ||
|
@@ -149,13 +170,13 @@ func (s *AppealRepositoryTestSuite) TestGetByID() { | |
filters: &domain.ListAppealsFilter{ | ||
Q: "user", | ||
}, | ||
expectedResult: []*domain.Appeal{dummyAppeal}, | ||
expectedResult: []*domain.Appeal{dummyAppeals[0], dummyAppeals[1]}, | ||
}, | ||
{ | ||
filters: &domain.ListAppealsFilter{ | ||
AccountTypes: []string{"x-account-type"}, | ||
}, | ||
expectedResult: []*domain.Appeal{dummyAppeal}, | ||
expectedResult: []*domain.Appeal{dummyAppeals[0], dummyAppeals[1]}, | ||
}, | ||
} | ||
|
||
|
@@ -166,6 +187,16 @@ func (s *AppealRepositoryTestSuite) TestGetByID() { | |
}) | ||
} | ||
|
||
func (s *AppealRepositoryTestSuite) TestGetAppealsTotalCount() { | ||
|
||
s.Run("should return 0", func() { | ||
actualResult, actualError := s.repository.GetAppealsTotalCount(context.Background(), &domain.ListAppealsFilter{}) | ||
|
||
s.Equal(int64(0), actualResult) | ||
s.Nil(actualError) | ||
}) | ||
} | ||
|
||
func (s *AppealRepositoryTestSuite) TestFind() { | ||
timeNowPlusAnHour := time.Now().Add(time.Hour) | ||
dummyAppeals := []*domain.Appeal{ | ||
|
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