Skip to content

Commit

Permalink
chore: fix test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Lifosmin Simon authored and Lifosmin Simon committed Aug 29, 2023
1 parent 843f6ec commit 79b1e6c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
1 change: 0 additions & 1 deletion api/handler/v1beta1/appeal.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func (s *GRPCServer) ListUserAppeals(ctx context.Context, req *guardianv1beta1.L
if req.GetAccountTypes() != nil {
filters.AccountTypes = req.GetAccountTypes()
}

if req.GetResourceUrns() != nil {
filters.ResourceURNs = req.GetResourceUrns()
}
Expand Down
36 changes: 36 additions & 0 deletions internal/store/postgres/appeal_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,42 @@ func (s *AppealRepositoryTestSuite) TestGetByID() {
s.Nil(actualError)
s.Equal(dummyAppeal.ID, actualRecord.ID)
})

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]",
}
testCases := []struct {
filters *domain.ListAppealsFilter
expectedArgs []driver.Value
expectedResult []*domain.Appeal
}{
{
filters: &domain.ListAppealsFilter{
Q: "user",
},
expectedResult: []*domain.Appeal{dummyAppeal},
},
{
filters: &domain.ListAppealsFilter{
AccountTypes: []string{"x-account-type"},
},
expectedResult: []*domain.Appeal{dummyAppeal},
},
}

for _, tc := range testCases {
_, actualError := s.repository.Find(context.Background(), tc.filters)
s.Nil(actualError)
}
})
}

func (s *AppealRepositoryTestSuite) TestFind() {
Expand Down

0 comments on commit 79b1e6c

Please sign in to comment.