Skip to content

Commit

Permalink
delete return check
Browse files Browse the repository at this point in the history
  • Loading branch information
senk8 committed Mar 5, 2024
1 parent 211ca64 commit ffd28fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/server/alert/alert_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (a *AlertService) RequestProjectRoleNotification(ctx context.Context, req *
}
default:
a.logger.Warnf(ctx, "This notification_type is unimplemented. type: %v", notification.Type)
return nil, fmt.Errorf("This notification_type is unavailable. type: %v", notification.Type)
return nil, fmt.Errorf("this notification_type is unavailable. type: %v", notification.Type)
}
return &empty.Empty{}, nil
}
Expand Down
12 changes: 1 addition & 11 deletions pkg/server/alert/alert_notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/ca-risken/common/pkg/logging"
"github.com/ca-risken/core/pkg/db/mocks"
"github.com/ca-risken/core/pkg/test"
"github.com/golang/protobuf/ptypes/empty"
"github.com/stretchr/testify/mock"
"gorm.io/gorm"

Expand Down Expand Up @@ -350,7 +349,6 @@ func TestRequestProjectRoleNotification(t *testing.T) {
cases := []struct {
name string
input *alert.RequestProjectRoleNotificationRequest
want *empty.Empty
wantErr bool
listNotification mockListNotification
listProject mockListProject
Expand All @@ -359,7 +357,6 @@ func TestRequestProjectRoleNotification(t *testing.T) {
{
name: "OK Request project role",
input: &alert.RequestProjectRoleNotificationRequest{ProjectId: 1001, UserId: 1001},
want: &empty.Empty{},
wantErr: false,
listNotification: mockListNotification{
Resp: &[]model.Notification{
Expand All @@ -385,7 +382,6 @@ func TestRequestProjectRoleNotification(t *testing.T) {
{
name: "NG unimplemented notification type",
input: &alert.RequestProjectRoleNotificationRequest{ProjectId: 1001, UserId: 1001},
want: nil,
wantErr: true,
listNotification: mockListNotification{
Resp: &[]model.Notification{
Expand All @@ -411,7 +407,6 @@ func TestRequestProjectRoleNotification(t *testing.T) {
{
name: "NG ListNotification (Notification Not Found)",
input: &alert.RequestProjectRoleNotificationRequest{ProjectId: 1001, UserId: 1001},
want: nil,
wantErr: true,
listNotification: mockListNotification{
Resp: &[]model.Notification{},
Expand All @@ -421,7 +416,6 @@ func TestRequestProjectRoleNotification(t *testing.T) {
{
name: "NG ListProject (API Error)",
input: &alert.RequestProjectRoleNotificationRequest{ProjectId: 1001, UserId: 1001},
want: nil,
wantErr: true,
listNotification: mockListNotification{
Resp: &[]model.Notification{
Expand All @@ -441,7 +435,6 @@ func TestRequestProjectRoleNotification(t *testing.T) {
{
name: "NG GetUser (API Error)",
input: &alert.RequestProjectRoleNotificationRequest{ProjectId: 1001, UserId: 1001},
want: nil,
wantErr: true,
listNotification: mockListNotification{
Resp: &[]model.Notification{
Expand Down Expand Up @@ -475,13 +468,10 @@ func TestRequestProjectRoleNotification(t *testing.T) {
mockIAM.On("GetUser", mock.Anything, mock.Anything).Return(c.getUser.Resp, c.getUser.Err)

svc := AlertService{projectClient: &mockProject, iamClient: &mockIAM, repository: mockDB, logger: logging.NewLogger()}
got, err := svc.RequestProjectRoleNotification(ctx, c.input)
_, err := svc.RequestProjectRoleNotification(ctx, c.input)
if err != nil && !c.wantErr {
t.Fatalf("Unexpected error: %+v", err)
}
if !reflect.DeepEqual(got, c.want) {
t.Fatalf("Unexpected response: want=%+v, got=%+v", c.want, got)
}
})
}
}

0 comments on commit ffd28fd

Please sign in to comment.