MM-67119: Remove unused Channel.Etag (#34951)

* Remove unused Channel.Etag

Computing the etag for a channel is complex due to user-specific data,
so we remove the unused Etag function to avoid confusion until a
performance need for it arises.

* Remove etag from Client4.GetChannel and tests

* make mocks

* Fix missing GetChannel calls
This commit is contained in:
Alejandro García Montoro 2026-01-20 17:46:17 +01:00 committed by GitHub
parent 3ebc90bde0
commit 5e99f12c3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 88 additions and 94 deletions

View file

@ -255,7 +255,7 @@ func TestCreateChannel(t *testing.T) {
require.NoError(t, err)
// Verify that the guest user can access the private channel they were added to
_, _, err = guestClient.GetChannel(context.Background(), private.Id, "")
_, _, err = guestClient.GetChannel(context.Background(), private.Id)
require.NoError(t, err)
// Verify that the guest user cannot add members to the private channel
@ -268,7 +268,7 @@ func TestCreateChannel(t *testing.T) {
require.NoError(t, err)
// Verify that the guest user can access the public channel they were added to
_, _, err = guestClient.GetChannel(context.Background(), public.Id, "")
_, _, err = guestClient.GetChannel(context.Background(), public.Id)
require.NoError(t, err)
// Verify that the guest user cannot add members to the public channel
@ -1624,50 +1624,50 @@ func TestGetChannel(t *testing.T) {
th := Setup(t).InitBasic(t)
client := th.Client
channel, _, err := client.GetChannel(context.Background(), th.BasicChannel.Id, "")
channel, _, err := client.GetChannel(context.Background(), th.BasicChannel.Id)
require.NoError(t, err)
require.Equal(t, th.BasicChannel.Id, channel.Id, "ids did not match")
_, err = client.RemoveUserFromChannel(context.Background(), th.BasicChannel.Id, th.BasicUser.Id)
require.NoError(t, err)
_, _, err = client.GetChannel(context.Background(), th.BasicChannel.Id, "")
_, _, err = client.GetChannel(context.Background(), th.BasicChannel.Id)
require.NoError(t, err)
channel, _, err = client.GetChannel(context.Background(), th.BasicPrivateChannel.Id, "")
channel, _, err = client.GetChannel(context.Background(), th.BasicPrivateChannel.Id)
require.NoError(t, err)
require.Equal(t, th.BasicPrivateChannel.Id, channel.Id, "ids did not match")
_, err = client.RemoveUserFromChannel(context.Background(), th.BasicPrivateChannel.Id, th.BasicUser.Id)
require.NoError(t, err)
_, resp, err := client.GetChannel(context.Background(), th.BasicPrivateChannel.Id, "")
_, resp, err := client.GetChannel(context.Background(), th.BasicPrivateChannel.Id)
require.Error(t, err)
CheckForbiddenStatus(t, resp)
_, resp, err = client.GetChannel(context.Background(), model.NewId(), "")
_, resp, err = client.GetChannel(context.Background(), model.NewId())
require.Error(t, err)
CheckNotFoundStatus(t, resp)
_, err = client.Logout(context.Background())
require.NoError(t, err)
_, resp, err = client.GetChannel(context.Background(), th.BasicChannel.Id, "")
_, resp, err = client.GetChannel(context.Background(), th.BasicChannel.Id)
require.Error(t, err)
CheckUnauthorizedStatus(t, resp)
user := th.CreateUser(t)
_, _, err = client.Login(context.Background(), user.Email, user.Password)
require.NoError(t, err)
_, resp, err = client.GetChannel(context.Background(), th.BasicChannel.Id, "")
_, resp, err = client.GetChannel(context.Background(), th.BasicChannel.Id)
require.Error(t, err)
CheckForbiddenStatus(t, resp)
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
_, _, err = client.GetChannel(context.Background(), th.BasicChannel.Id, "")
_, _, err = client.GetChannel(context.Background(), th.BasicChannel.Id)
require.NoError(t, err)
_, _, err = client.GetChannel(context.Background(), th.BasicPrivateChannel.Id, "")
_, _, err = client.GetChannel(context.Background(), th.BasicPrivateChannel.Id)
require.NoError(t, err)
_, resp, err = client.GetChannel(context.Background(), th.BasicUser.Id, "")
_, resp, err = client.GetChannel(context.Background(), th.BasicUser.Id)
require.Error(t, err)
CheckNotFoundStatus(t, resp)
})
@ -3644,7 +3644,7 @@ func TestViewChannel(t *testing.T) {
member, _, err := client.GetChannelMember(context.Background(), th.BasicChannel.Id, th.BasicUser.Id, "")
require.NoError(t, err)
channel, _, err = client.GetChannel(context.Background(), th.BasicChannel.Id, "")
channel, _, err = client.GetChannel(context.Background(), th.BasicChannel.Id)
require.NoError(t, err)
require.Equal(t, channel.TotalMsgCount, member.MsgCount, "should match message counts")
require.Equal(t, int64(0), member.MentionCount, "should have no mentions")
@ -3679,9 +3679,9 @@ func TestReadMultipleChannels(t *testing.T) {
user := th.BasicUser
t.Run("Should successfully mark public channels as read for self", func(t *testing.T) {
channel, _, err := client.GetChannel(context.Background(), th.BasicChannel.Id, "")
channel, _, err := client.GetChannel(context.Background(), th.BasicChannel.Id)
require.NoError(t, err)
channel2, _, err := client.GetChannel(context.Background(), th.BasicChannel2.Id, "")
channel2, _, err := client.GetChannel(context.Background(), th.BasicChannel2.Id)
require.NoError(t, err)
channelResponse, _, err := client.ReadMultipleChannels(context.Background(), user.Id, []string{channel.Id, channel2.Id})
@ -3692,7 +3692,7 @@ func TestReadMultipleChannels(t *testing.T) {
})
t.Run("Should successfully mark private channels as read for self", func(t *testing.T) {
channel, _, err := client.GetChannel(context.Background(), th.BasicPrivateChannel.Id, "")
channel, _, err := client.GetChannel(context.Background(), th.BasicPrivateChannel.Id)
require.NoError(t, err)
// private channel without membership should be ignored
@ -3704,7 +3704,7 @@ func TestReadMultipleChannels(t *testing.T) {
})
t.Run("Should fail marking public/private channels for other user", func(t *testing.T) {
channel, _, err := client.GetChannel(context.Background(), th.BasicChannel.Id, "")
channel, _, err := client.GetChannel(context.Background(), th.BasicChannel.Id)
require.NoError(t, err)
_, _, err = client.ReadMultipleChannels(context.Background(), th.BasicUser2.Id, []string{channel.Id})
@ -3713,9 +3713,9 @@ func TestReadMultipleChannels(t *testing.T) {
t.Run("Admin should succeed in marking public/private channels for other user", func(t *testing.T) {
adminClient := th.SystemAdminClient
channel, _, err := adminClient.GetChannel(context.Background(), th.BasicChannel.Id, "")
channel, _, err := adminClient.GetChannel(context.Background(), th.BasicChannel.Id)
require.NoError(t, err)
privateChannel, _, err := adminClient.GetChannel(context.Background(), th.BasicPrivateChannel.Id, "")
privateChannel, _, err := adminClient.GetChannel(context.Background(), th.BasicPrivateChannel.Id)
require.NoError(t, err)
channelResponse, _, err := adminClient.ReadMultipleChannels(context.Background(), th.BasicUser2.Id, []string{channel.Id, privateChannel.Id})
@ -3729,9 +3729,9 @@ func TestReadMultipleChannels(t *testing.T) {
th.LoginSystemManager(t)
sysMgrClient := th.SystemManagerClient
channel, _, err := sysMgrClient.GetChannel(context.Background(), th.BasicChannel.Id, "")
channel, _, err := sysMgrClient.GetChannel(context.Background(), th.BasicChannel.Id)
require.NoError(t, err)
privateChannel, _, err := sysMgrClient.GetChannel(context.Background(), th.BasicPrivateChannel.Id, "")
privateChannel, _, err := sysMgrClient.GetChannel(context.Background(), th.BasicPrivateChannel.Id)
require.NoError(t, err)
_, _, err = sysMgrClient.ReadMultipleChannels(context.Background(), th.BasicUser2.Id, []string{channel.Id, privateChannel.Id})

View file

@ -28,7 +28,7 @@ type Client interface {
PatchChannel(ctx context.Context, channelID string, patch *model.ChannelPatch) (*model.Channel, *model.Response, error)
GetChannelByName(ctx context.Context, channelName, teamID string, etag string) (*model.Channel, *model.Response, error)
GetChannelByNameIncludeDeleted(ctx context.Context, channelName, teamID string, etag string) (*model.Channel, *model.Response, error)
GetChannel(ctx context.Context, channelID, etag string) (*model.Channel, *model.Response, error)
GetChannel(ctx context.Context, channelID string) (*model.Channel, *model.Response, error)
GetTeam(ctx context.Context, teamID, etag string) (*model.Team, *model.Response, error)
GetTeamByName(ctx context.Context, name, etag string) (*model.Team, *model.Response, error)
GetAllTeams(ctx context.Context, etag string, page int, perPage int) ([]*model.Team, *model.Response, error)

View file

@ -192,7 +192,7 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), args[0], "").
GetChannel(context.TODO(), args[0]).
Return(nil, &model.Response{}, errors.New("")).
Times(1)
@ -246,7 +246,7 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), args[0], "").
GetChannel(context.TODO(), args[0]).
Return(channel, &model.Response{}, nil).
Times(1)
@ -271,7 +271,7 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), args[0], "").
GetChannel(context.TODO(), args[0]).
Return(channel, &model.Response{}, nil).
Times(1)
@ -298,7 +298,7 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), args[0], "").
GetChannel(context.TODO(), args[0]).
Return(channel, &model.Response{}, nil).
Times(1)
@ -333,7 +333,7 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), args[0], "").
GetChannel(context.TODO(), args[0]).
Return(channel, &model.Response{}, nil).
Times(1)
@ -368,7 +368,7 @@ func (s *MmctlUnitTestSuite) TestModifyChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), args[0], "").
GetChannel(context.TODO(), args[0]).
Return(channel, &model.Response{}, nil).
Times(1)
@ -443,7 +443,7 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -475,13 +475,13 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg1, "").
GetChannel(context.TODO(), channelArg1).
Return(&mockChannel1, &model.Response{}, nil).
Times(1)
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg2, "").
GetChannel(context.TODO(), channelArg2).
Return(&mockChannel2, &model.Response{}, nil).
Times(1)
@ -558,7 +558,7 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg, "").
GetChannel(context.TODO(), channelArg).
Return(nil, &model.Response{}, nil).
Times(1)
@ -581,7 +581,7 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg, "").
GetChannel(context.TODO(), channelArg).
Return(nil, &model.Response{}, nil).
Times(1)
@ -607,7 +607,7 @@ func (s *MmctlUnitTestSuite) TestArchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg, "").
GetChannel(context.TODO(), channelArg).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -1702,7 +1702,7 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -1734,13 +1734,13 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg1, "").
GetChannel(context.TODO(), channelArg1).
Return(&mockChannel1, &model.Response{}, nil).
Times(1)
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg2, "").
GetChannel(context.TODO(), channelArg2).
Return(&mockChannel2, &model.Response{}, nil).
Times(1)
@ -1816,7 +1816,7 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg, "").
GetChannel(context.TODO(), channelArg).
Return(nil, &model.Response{}, nil).
Times(1)
@ -1839,7 +1839,7 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg, "").
GetChannel(context.TODO(), channelArg).
Return(nil, &model.Response{}, nil).
Times(1)
@ -1863,7 +1863,7 @@ func (s *MmctlUnitTestSuite) TestUnarchiveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -1975,7 +1975,7 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(nil, &model.Response{}, nil).
Times(1)
@ -2000,7 +2000,7 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(nil, &model.Response{}, nil).
Times(1)
@ -2078,7 +2078,7 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(nil, &model.Response{}, nil).
Times(1)
@ -2245,7 +2245,7 @@ func (s *MmctlUnitTestSuite) TestRenameChannelCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(foundChannel, &model.Response{}, nil).
Times(1)
@ -2512,7 +2512,7 @@ func (s *MmctlUnitTestSuite) TestMoveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelID, "").
GetChannel(context.TODO(), channelID).
Return(nil, &model.Response{}, errors.New("")).
Times(1)
@ -2543,7 +2543,7 @@ func (s *MmctlUnitTestSuite) TestMoveChannelCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelID, "").
GetChannel(context.TODO(), channelID).
Return(&model.Channel{Id: channelID, Name: "some-name"}, &model.Response{}, nil).
Times(1)
@ -2838,7 +2838,7 @@ func (s *MmctlUnitTestSuite) TestDeleteChannelsCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(nil, &model.Response{}, nil).
Times(1)
@ -2927,7 +2927,7 @@ func (s *MmctlUnitTestSuite) TestDeleteChannelsCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelNameDoesNotExist, "").
GetChannel(context.TODO(), channelNameDoesNotExist).
Return(nil, &model.Response{}, mockError).
Times(1)

View file

@ -87,7 +87,7 @@ func (s *MmctlUnitTestSuite) TestChannelUsersAddCmdF() {
Times(1)
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(nil, &model.Response{}, nil).
Times(1)

View file

@ -55,7 +55,7 @@ func getChannelFromChannelArg(c client.Client, channelArg string) *model.Channel
}
if channel == nil {
channel, _, _ = c.GetChannel(context.TODO(), channelPart, "")
channel, _, _ = c.GetChannel(context.TODO(), channelPart)
}
return channel
@ -109,7 +109,7 @@ func getChannelFromArg(c client.Client, arg string) (*model.Channel, error) {
return channel, nil
}
var err error
channel, response, err = c.GetChannel(context.TODO(), channelArg, "")
channel, response, err = c.GetChannel(context.TODO(), channelArg)
if err != nil {
nErr := ExtractErrorFromResponse(response, err)
var nfErr *NotFoundError

View file

@ -19,7 +19,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() {
s.client.
EXPECT().
GetChannel(context.TODO(), notFoundChannel, "").
GetChannel(context.TODO(), notFoundChannel).
Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr).
Times(1)
@ -34,7 +34,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() {
s.client.
EXPECT().
GetChannel(context.TODO(), badRequestChannel, "").
GetChannel(context.TODO(), badRequestChannel).
Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr).
Times(1)
@ -49,7 +49,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() {
s.client.
EXPECT().
GetChannel(context.TODO(), forbidden, "").
GetChannel(context.TODO(), forbidden).
Return(nil, &model.Response{StatusCode: http.StatusForbidden}, forbiddenErr).
Times(1)
@ -64,7 +64,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() {
s.client.
EXPECT().
GetChannel(context.TODO(), errChannel, "").
GetChannel(context.TODO(), errChannel).
Return(nil, &model.Response{StatusCode: http.StatusInternalServerError}, internalServerErrorErr).
Times(1)
@ -79,7 +79,7 @@ func (s *MmctlUnitTestSuite) TestGetChannelArgs() {
s.client.
EXPECT().
GetChannel(context.TODO(), successID, "").
GetChannel(context.TODO(), successID).
Return(successChannel, nil, nil).
Times(1)

View file

@ -454,7 +454,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelID, "").
GetChannel(context.TODO(), channelID).
Return(nil, &model.Response{}, nil).
Times(1)
@ -560,7 +560,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupListCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelID, "").
GetChannel(context.TODO(), channelID).
Return(nil, &model.Response{}, mockError).
Times(1)
@ -853,7 +853,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupStatusCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelID, "").
GetChannel(context.TODO(), channelID).
Return(nil, &model.Response{}, nil).
Times(1)
@ -1057,7 +1057,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelPart, "").
GetChannel(context.TODO(), channelPart).
Return(nil, &model.Response{}, mockError).
Times(1)
@ -1247,7 +1247,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelPart, "").
GetChannel(context.TODO(), channelPart).
Return(nil, &model.Response{}, nil).
Times(1)
@ -1290,7 +1290,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupEnableCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelPart, "").
GetChannel(context.TODO(), channelPart).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -1395,7 +1395,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelPart, "").
GetChannel(context.TODO(), channelPart).
Return(nil, &model.Response{}, nil).
Times(1)
@ -1496,7 +1496,7 @@ func (s *MmctlUnitTestSuite) TestChannelGroupDisableCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelPart, "").
GetChannel(context.TODO(), channelPart).
Return(nil, &model.Response{}, mockError).
Times(1)

View file

@ -64,7 +64,7 @@ func (s *MmctlUnitTestSuite) TestPostCreateCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg, "").
GetChannel(context.TODO(), channelArg).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -91,7 +91,7 @@ func (s *MmctlUnitTestSuite) TestPostCreateCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg, "").
GetChannel(context.TODO(), channelArg).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -123,7 +123,7 @@ func (s *MmctlUnitTestSuite) TestPostCreateCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelArg, "").
GetChannel(context.TODO(), channelArg).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -162,7 +162,7 @@ func (s *MmctlUnitTestSuite) TestPostListCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -187,7 +187,7 @@ func (s *MmctlUnitTestSuite) TestPostListCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -235,7 +235,7 @@ func (s *MmctlUnitTestSuite) TestPostListCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)

View file

@ -38,7 +38,7 @@ func (s *MmctlUnitTestSuite) TestReportPostsCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -61,7 +61,7 @@ func (s *MmctlUnitTestSuite) TestReportPostsCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -84,7 +84,7 @@ func (s *MmctlUnitTestSuite) TestReportPostsCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -107,7 +107,7 @@ func (s *MmctlUnitTestSuite) TestReportPostsCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -131,7 +131,7 @@ func (s *MmctlUnitTestSuite) TestReportPostsCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -179,7 +179,7 @@ func (s *MmctlUnitTestSuite) TestReportPostsCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -229,7 +229,7 @@ func (s *MmctlUnitTestSuite) TestReportPostsCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -278,7 +278,7 @@ func (s *MmctlUnitTestSuite) TestReportPostsCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -328,7 +328,7 @@ func (s *MmctlUnitTestSuite) TestReportPostsCmdF() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelName, "").
GetChannel(context.TODO(), channelName).
Return(&mockChannel, &model.Response{}, nil).
Times(1)

View file

@ -265,7 +265,7 @@ func (s *MmctlUnitTestSuite) TestCreateIncomingWebhookCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelID, "").
GetChannel(context.TODO(), channelID).
Return(&mockChannel, &model.Response{}, nil).
Times(1)
@ -309,7 +309,7 @@ func (s *MmctlUnitTestSuite) TestCreateIncomingWebhookCmd() {
s.client.
EXPECT().
GetChannel(context.TODO(), channelID, "").
GetChannel(context.TODO(), channelID).
Return(&mockChannel, &model.Response{}, nil).
Times(1)

View file

@ -715,9 +715,9 @@ func (mr *MockClientMockRecorder) GetBotsOrphaned(arg0, arg1, arg2, arg3 interfa
}
// GetChannel mocks base method.
func (m *MockClient) GetChannel(arg0 context.Context, arg1, arg2 string) (*model.Channel, *model.Response, error) {
func (m *MockClient) GetChannel(arg0 context.Context, arg1 string) (*model.Channel, *model.Response, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetChannel", arg0, arg1, arg2)
ret := m.ctrl.Call(m, "GetChannel", arg0, arg1)
ret0, _ := ret[0].(*model.Channel)
ret1, _ := ret[1].(*model.Response)
ret2, _ := ret[2].(error)
@ -725,9 +725,9 @@ func (m *MockClient) GetChannel(arg0 context.Context, arg1, arg2 string) (*model
}
// GetChannel indicates an expected call of GetChannel.
func (mr *MockClientMockRecorder) GetChannel(arg0, arg1, arg2 interface{}) *gomock.Call {
func (mr *MockClientMockRecorder) GetChannel(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChannel", reflect.TypeOf((*MockClient)(nil).GetChannel), arg0, arg1, arg2)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChannel", reflect.TypeOf((*MockClient)(nil).GetChannel), arg0, arg1)
}
// GetChannelByName mocks base method.

View file

@ -265,10 +265,6 @@ func (o *Channel) DeepCopy() *Channel {
return &cCopy
}
func (o *Channel) Etag() string {
return Etag(o.Id, o.UpdateAt)
}
func (o *Channel) IsValid() *AppError {
if !IsValidId(o.Id) {
return NewAppError("Channel.IsValid", "model.channel.is_valid.id.app_error", nil, "", http.StatusBadRequest)

View file

@ -152,7 +152,6 @@ func TestChannelBannerBackgroundColorValidation(t *testing.T) {
func TestChannelPreSave(t *testing.T) {
o := Channel{Name: "test"}
o.PreSave()
o.Etag()
}
func TestChannelPreUpdate(t *testing.T) {

View file

@ -2643,8 +2643,8 @@ func (c *Client4) CreateGroupChannel(ctx context.Context, userIds []string) (*Ch
}
// GetChannel returns a channel based on the provided channel id string.
func (c *Client4) GetChannel(ctx context.Context, channelId, etag string) (*Channel, *Response, error) {
r, err := c.DoAPIGet(ctx, c.channelRoute(channelId), etag)
func (c *Client4) GetChannel(ctx context.Context, channelId string) (*Channel, *Response, error) {
r, err := c.DoAPIGet(ctx, c.channelRoute(channelId), "")
if err != nil {
return nil, BuildResponse(r), err
}

View file

@ -102,8 +102,7 @@ func ExampleClient4_GetChannel() {
client.SetToken(os.Getenv("MM_AUTHTOKEN"))
channelId := "channel_id"
etag := ""
channel, _, err := client.GetChannel(context.Background(), channelId, etag)
channel, _, err := client.GetChannel(context.Background(), channelId)
if err != nil {
log.Fatal(err)
}