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

102 lines
3.0 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package commands
import (
"context"
"fmt"
"net/http"
"github.com/hanzoteam/server/server/public/model"
"github.com/pkg/errors"
)
func (s *MmctlUnitTestSuite) TestGetTeamArgs() {
s.Run("team not found", func() {
notFoundTeam := "notfoundteam"
notFoundErr := errors.New("team not found")
s.client.
EXPECT().
GetTeam(context.TODO(), notFoundTeam, "").
Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr).
Times(1)
s.client.
EXPECT().
GetTeamByName(context.TODO(), notFoundTeam, "").
Return(nil, &model.Response{StatusCode: http.StatusNotFound}, notFoundErr).
Times(1)
teams, err := getTeamsFromArgs(s.client, []string{notFoundTeam})
s.Require().Empty(teams)
s.Require().NotNil(err)
s.Require().EqualError(err, fmt.Sprintf("1 error occurred:\n\t* team %s not found\n\n", notFoundTeam))
})
s.Run("bad request", func() {
badRequestTeam := "badrequest"
badRequestErr := errors.New("team bad request")
s.client.
EXPECT().
GetTeam(context.TODO(), badRequestTeam, "").
Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr).
Times(1)
s.client.
EXPECT().
GetTeamByName(context.TODO(), badRequestTeam, "").
Return(nil, &model.Response{StatusCode: http.StatusBadRequest}, badRequestErr).
Times(1)
teams, err := getTeamsFromArgs(s.client, []string{badRequestTeam})
s.Require().Empty(teams)
s.Require().NotNil(err)
s.Require().EqualError(err, fmt.Sprintf("1 error occurred:\n\t* team %s not found\n\n", badRequestTeam))
})
s.Run("forbidden", func() {
forbidden := "forbidden"
forbiddenErr := errors.New("team forbidden")
s.client.
EXPECT().
GetTeam(context.TODO(), forbidden, "").
Return(nil, &model.Response{StatusCode: http.StatusForbidden}, forbiddenErr).
Times(1)
teams, err := getTeamsFromArgs(s.client, []string{forbidden})
s.Require().Empty(teams)
s.Require().NotNil(err)
s.Require().EqualError(err, "1 error occurred:\n\t* team forbidden\n\n")
})
s.Run("internal server error", func() {
errTeam := "internalServerError"
internalServerErrorErr := errors.New("team internalServerError")
s.client.
EXPECT().
GetTeam(context.TODO(), errTeam, "").
Return(nil, &model.Response{StatusCode: http.StatusInternalServerError}, internalServerErrorErr).
Times(1)
teams, err := getTeamsFromArgs(s.client, []string{errTeam})
s.Require().Empty(teams)
s.Require().NotNil(err)
s.Require().EqualError(err, "1 error occurred:\n\t* team internalServerError\n\n")
})
s.Run("success", func() {
successID := "[email protected]"
successTeam := &model.Team{Id: successID}
s.client.
EXPECT().
GetTeam(context.TODO(), successID, "").
Return(successTeam, nil, nil).
Times(1)
teams, summary := getTeamsFromArgs(s.client, []string{successID})
s.Require().Nil(summary)
s.Require().Len(teams, 1)
s.Require().Equal(successTeam, teams[0])
})
}