Files
zeekay 8feb24ea1f One name for this fork, and it is ours
The server module named github.com/hanzoai/team/server/v8 — a path that
resolves to the retired workspace's repository, not this one — while
server/public still published github.com/mattermost/mattermost/server/public.
Both are github.com/hanzoteam/server/... now, which is where this code
actually lives.

That second half is what made the binary unbootable. Upstream's public path
stayed claimed by upstream, mattermost-plugin-ai imported it, and the build
linked public/model twice; public/plugin's gob.Register then ran twice under
one name and panicked at init, before main. Reverting the rename traded the
brand for a working binary. Rebranding the plugin alongside it needs no such
trade: the agents fork is github.com/hanzoteam/agents/v2 against our public
module, so no module named mattermost/mattermost is in the graph at all.

Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and
it is ours.
2026-08-28 23:35:36 -07:00

115 lines
3.4 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package commands
import (
"context"
"errors"
"fmt"
"net/http"
"github.com/hanzoteam/server/server/public/model"
)
func (s *MmctlUnitTestSuite) TestGetChannelArgs() {
s.Run("channel not found", func() {
notFoundChannel := "notfoundchannel"
notFoundErr := errors.New("channel not found")
s.client.
EXPECT().
GetChannel(context.TODO(), notFoundChannel).
Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr).
Times(1)
channels, err := getChannelsFromArgs(s.client, []string{notFoundChannel})
s.Require().Empty(channels)
s.Require().NotNil(err)
s.Require().EqualError(err, fmt.Sprintf("1 error occurred:\n\t* channel %s not found\n\n", notFoundChannel))
})
s.Run("bad request", func() {
badRequestChannel := "badrequest"
badRequestErr := errors.New("channel bad request")
s.client.
EXPECT().
GetChannel(context.TODO(), badRequestChannel).
Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr).
Times(1)
channels, err := getChannelsFromArgs(s.client, []string{badRequestChannel})
s.Require().Empty(channels)
s.Require().NotNil(err)
s.Require().EqualError(err, fmt.Sprintf("1 error occurred:\n\t* channel %s not found\n\n", badRequestChannel))
})
s.Run("forbidden", func() {
forbidden := "forbidden"
forbiddenErr := errors.New("channel forbidden")
s.client.
EXPECT().
GetChannel(context.TODO(), forbidden).
Return(nil, &model.Response{StatusCode: http.StatusForbidden}, forbiddenErr).
Times(1)
channels, err := getChannelsFromArgs(s.client, []string{forbidden})
s.Require().Empty(channels)
s.Require().NotNil(err)
s.Require().EqualError(err, "1 error occurred:\n\t* channel forbidden\n\n")
})
s.Run("internal server error", func() {
errChannel := "internalServerError"
internalServerErrorErr := errors.New("channel internalServerError")
s.client.
EXPECT().
GetChannel(context.TODO(), errChannel).
Return(nil, &model.Response{StatusCode: http.StatusInternalServerError}, internalServerErrorErr).
Times(1)
channels, err := getChannelsFromArgs(s.client, []string{errChannel})
s.Require().Empty(channels)
s.Require().NotNil(err)
s.Require().EqualError(err, "1 error occurred:\n\t* channel internalServerError\n\n")
})
s.Run("success", func() {
successID := "success"
successChannel := &model.Channel{Id: successID}
s.client.
EXPECT().
GetChannel(context.TODO(), successID).
Return(successChannel, nil, nil).
Times(1)
channels, summary := getChannelsFromArgs(s.client, []string{successID})
s.Require().Nil(summary)
s.Require().Len(channels, 1)
s.Require().Equal(successChannel, channels[0])
})
s.Run("success with team on channel", func() {
channelID := "success"
teamID := "myTeamID"
successTeam := &model.Team{Id: teamID}
successChannel := &model.Channel{Id: channelID}
s.client.
EXPECT().
GetTeam(context.TODO(), teamID, "").
Return(successTeam, nil, nil).
Times(1)
s.client.
EXPECT().
GetChannelByNameIncludeDeleted(context.TODO(), channelID, teamID, "").
Return(successChannel, nil, nil).
Times(1)
channels, summary := getChannelsFromArgs(s.client, []string{fmt.Sprintf("%v:%v", teamID, channelID)})
s.Require().Nil(summary)
s.Require().Len(channels, 1)
s.Require().Equal(successChannel, channels[0])
})
}