Skip to content

Commit

Permalink
fix user tests
Browse files Browse the repository at this point in the history
  • Loading branch information
almostinf committed Dec 5, 2023
1 parent b98994b commit f2f168c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions user/internal/api/grpc/controller/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ func ChangeUserRole(ctx context.Context, userUsecase usecase.IUserUsecase, req *
return nil, status.Errorf(codes.InvalidArgument, "Invalid user id: %s", err)
}

if req.Role == pbUser.UserRole_SUPERADMIN || req.Role == pbUser.UserRole_GUEST {
return nil, status.Errorf(codes.InvalidArgument, "Invalid role request: %s", err)
if req.Role >= pbUser.UserRole_SUPERADMIN || req.Role <= pbUser.UserRole_GUEST {
return nil, status.Errorf(codes.InvalidArgument, "Invalid role request")
}

user, err := userUsecase.ChangeUserRole(ctx, userID, model.UserRoles(req.Role))
Expand Down
2 changes: 1 addition & 1 deletion user/internal/api/grpc/controller/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestChangeUserRole(t *testing.T) {
},
mock: func(usecase *mocks.MockIUserUsecase) {},
expectedUser: nil,
expectedErr: status.Errorf(codes.InvalidArgument, "Invalid request: %s", fmt.Errorf("Key: 'User.Role' Error:Field validation for 'Role' failed on the 'oneof' tag")),
expectedErr: status.Errorf(codes.InvalidArgument, "Invalid role request"),
},
{
name: "Got error when change user role in usecase",
Expand Down

0 comments on commit f2f168c

Please sign in to comment.