[MM-62179] Fix: mmctl debug error when setting email (#29953)
* only GetUserByEmail if arg is an email * fixing tests * fix typo
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
05ca61c784
Коммит
28c561d643
@@ -57,13 +57,13 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() {
|
||||
EXPECT().
|
||||
GetUserByEmail(context.TODO(), userEmail, "").
|
||||
Return(&mockUser, &model.Response{}, nil).
|
||||
Times(1)
|
||||
Times(3)
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
AddChannelMember(context.TODO(), channelID, userID).
|
||||
Return(&model.ChannelMember{}, &model.Response{}, nil).
|
||||
Times(1)
|
||||
Times(2)
|
||||
err := channelUsersAddCmdF(s.client, cmd, []string{channelArg, userEmail})
|
||||
s.Require().Nil(err)
|
||||
s.Len(printer.GetLines(), 0)
|
||||
@@ -133,11 +133,6 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() {
|
||||
GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, "").
|
||||
Return(&mockChannel, &model.Response{}, nil).
|
||||
Times(1)
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetUserByEmail(context.TODO(), nilUserArg, "").
|
||||
Return(nil, &model.Response{}, nil).
|
||||
Times(1)
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetUserByUsername(context.TODO(), nilUserArg, "").
|
||||
@@ -148,16 +143,6 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() {
|
||||
GetUser(context.TODO(), nilUserArg, "").
|
||||
Return(nil, &model.Response{}, nil).
|
||||
Times(1)
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetUserByEmail(context.TODO(), userEmail, "").
|
||||
Return(&mockUser, &model.Response{}, nil).
|
||||
Times(1)
|
||||
s.client.
|
||||
EXPECT().
|
||||
AddChannelMember(context.TODO(), channelID, userID).
|
||||
Return(&model.ChannelMember{}, &model.Response{}, nil).
|
||||
Times(1)
|
||||
err := channelUsersAddCmdF(s.client, cmd, []string{channelArg, nilUserArg, userEmail})
|
||||
s.Require().ErrorContains(err, "unable to find user")
|
||||
s.Require().ErrorContains(err, nilUserArg)
|
||||
@@ -179,11 +164,6 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() {
|
||||
GetChannelByNameIncludeDeleted(context.TODO(), channelName, teamID, "").
|
||||
Return(&mockChannel, &model.Response{}, nil).
|
||||
Times(1)
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetUserByEmail(context.TODO(), userEmail, "").
|
||||
Return(&mockUser, &model.Response{}, nil).
|
||||
Times(1)
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
@@ -293,6 +273,12 @@ func (s *MmctlUnitTestSuite) TestChannelUsersRemoveCmd() {
|
||||
Return(foundTeam, &model.Response{}, nil).
|
||||
Times(1)
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetUserByEmail(context.TODO(), userEmail, "").
|
||||
Return(&mockUser, &model.Response{}, nil).
|
||||
Times(1)
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetChannelByNameIncludeDeleted(context.TODO(), channelName, foundTeam.Id, "").
|
||||
@@ -367,7 +353,7 @@ func (s *MmctlUnitTestSuite) TestChannelUsersRemoveCmd() {
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetUserByEmail(context.TODO(), mockUser2.Email, "").
|
||||
GetUserByUsername(context.TODO(), mockUser2.Email, "").
|
||||
Return(&mockUser2, &model.Response{}, nil).
|
||||
Times(1)
|
||||
|
||||
@@ -470,12 +456,6 @@ func (s *MmctlUnitTestSuite) TestChannelUsersRemoveCmd() {
|
||||
Return(foundChannel, &model.Response{}, nil).
|
||||
Times(1)
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
GetUserByEmail(context.TODO(), userEmail, "").
|
||||
Return(&mockUser, &model.Response{}, nil).
|
||||
Times(1)
|
||||
|
||||
s.client.
|
||||
EXPECT().
|
||||
RemoveUserFromChannel(context.TODO(), foundChannel.Id, mockUser.Id).
|
||||
|
||||
Ссылка в новой задаче
Block a user