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(approvers): duplicated approver is not allowed (#135)
* fix(approvers): duplicated approver is not allowed * test: adding unit test * chore: update error log Co-authored-by: Rahmat Hidayat <[email protected]> --------- Co-authored-by: Muhammad Idil Haq Amir <[email protected]> Co-authored-by: Rahmat Hidayat <[email protected]>
- Loading branch information
1 parent
9643b56
commit a2376bb
Showing
3 changed files
with
30 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,3 +80,4 @@ setup: | |
go get github.com/grpc-ecosystem/grpc-gateway/v2/[email protected] | ||
go get github.com/bufbuild/buf/cmd/[email protected] | ||
go get github.com/vektra/mockery/[email protected] | ||
|
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 |
---|---|---|
|
@@ -3177,6 +3177,30 @@ func (s *ServiceTestSuite) TestAddApprover() { | |
s.ErrorIs(err, expectedError) | ||
s.mockRepository.AssertExpectations(s.T()) | ||
}) | ||
|
||
s.Run("should return error if the new approver is already exist on the current approval", func() { | ||
expectedError := appeal.ErrUnableToAddApprover | ||
approvalID := uuid.New().String() | ||
expectedAppeal := &domain.Appeal{ | ||
Status: domain.AppealStatusPending, | ||
Approvals: []*domain.Approval{ | ||
{ | ||
ID: approvalID, | ||
Status: domain.ApprovalStatusPending, | ||
Approvers: []string{"[email protected]"}, | ||
}, | ||
}, | ||
} | ||
s.mockRepository.EXPECT(). | ||
GetByID(mock.MatchedBy(func(ctx context.Context) bool { return true }), mock.Anything). | ||
Return(expectedAppeal, nil).Once() | ||
|
||
appeal, err := s.service.AddApprover(context.Background(), uuid.New().String(), approvalID, "[email protected]") | ||
|
||
s.Nil(appeal) | ||
s.ErrorIs(err, expectedError) | ||
s.mockRepository.AssertExpectations(s.T()) | ||
}) | ||
} | ||
|
||
func (s *ServiceTestSuite) TestDeleteApprover() { | ||
|