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

143 lines
4.4 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package commands
import (
"time"
"github.com/hanzoteam/server/server/public/model"
"github.com/hanzoteam/server/server/v8/cmd/mmctl/client"
"github.com/hanzoteam/server/server/v8/cmd/mmctl/printer"
"github.com/spf13/cobra"
)
func (s *MmctlE2ETestSuite) TestCreateJobCmdF() {
s.SetupTestHelper().InitBasic(s.T())
newCmd := func() *cobra.Command {
cmd := &cobra.Command{}
cmd.Flags().StringToString("data", nil, "")
return cmd
}
s.Run("create a job without permissions", func() {
printer.Clean()
err := createJobCmdF(s.th.Client, newCmd(), []string{model.JobTypeExportProcess})
s.Require().EqualError(err, "failed to create job: You do not have the appropriate permissions.")
s.Require().Empty(printer.GetLines())
s.Require().Empty(printer.GetErrorLines())
})
s.RunForSystemAdminAndLocal("create a job", func(c client.Client) {
printer.Clean()
err := createJobCmdF(c, newCmd(), []string{model.JobTypeExportProcess})
s.Require().Nil(err)
s.Require().Empty(printer.GetErrorLines())
s.Require().Len(printer.GetLines(), 1)
s.Require().Equal(model.JobTypeExportProcess, printer.GetLines()[0].(*model.Job).Type)
})
s.RunForSystemAdminAndLocal("create a job with data", func(c client.Client) {
printer.Clean()
cmd := newCmd()
err := cmd.Flags().Set("data", "include_attachments=true")
s.Require().NoError(err)
err = createJobCmdF(c, cmd, []string{model.JobTypeExportProcess})
s.Require().Nil(err)
s.Require().Empty(printer.GetErrorLines())
s.Require().Len(printer.GetLines(), 1)
s.Require().Equal("true", printer.GetLines()[0].(*model.Job).Data["include_attachments"])
})
}
func (s *MmctlE2ETestSuite) TestShowJobCmdF() {
s.SetupTestHelper().InitBasic(s.T())
job, appErr := s.th.App.CreateJob(s.th.Context, &model.Job{
Type: model.JobTypeExportProcess,
})
s.Require().Nil(appErr)
s.Run("show a job without permissions", func() {
printer.Clean()
err := showJobCmdF(s.th.Client, &cobra.Command{}, []string{job.Id})
s.Require().EqualError(err, "failed to get job: You do not have the appropriate permissions.")
s.Require().Empty(printer.GetLines())
s.Require().Empty(printer.GetErrorLines())
})
s.RunForSystemAdminAndLocal("show a job that does not exist", func(c client.Client) {
printer.Clean()
err := showJobCmdF(c, &cobra.Command{}, []string{model.NewId()})
s.Require().ErrorContains(err, "failed to get job: Unable to get the job.")
s.Require().Empty(printer.GetLines())
s.Require().Empty(printer.GetErrorLines())
})
s.RunForSystemAdminAndLocal("show a job", func(c client.Client) {
printer.Clean()
err := showJobCmdF(c, &cobra.Command{}, []string{job.Id})
s.Require().Nil(err)
s.Require().Empty(printer.GetErrorLines())
s.Require().Len(printer.GetLines(), 1)
s.Require().Equal(job, printer.GetLines()[0].(*model.Job))
})
}
func (s *MmctlE2ETestSuite) TestCancelJobCmdF() {
s.SetupTestHelper().InitBasic(s.T())
s.Run("cancel a job without permissions", func() {
printer.Clean()
job, appErr := s.th.App.CreateJob(s.th.Context, &model.Job{
Type: model.JobTypeExportProcess,
})
s.Require().Nil(appErr)
err := cancelJobCmdF(s.th.Client, &cobra.Command{}, []string{job.Id})
s.Require().EqualError(err, "failed to cancel job: You do not have the appropriate permissions.")
s.Require().Empty(printer.GetLines())
s.Require().Empty(printer.GetErrorLines())
})
s.RunForSystemAdminAndLocal("cancel a job that does not exist", func(c client.Client) {
printer.Clean()
err := cancelJobCmdF(c, &cobra.Command{}, []string{model.NewId()})
s.Require().ErrorContains(err, "failed to cancel job: Unable to get the job.")
s.Require().Empty(printer.GetLines())
s.Require().Empty(printer.GetErrorLines())
})
s.RunForSystemAdminAndLocal("cancel a job", func(c client.Client) {
printer.Clean()
job, appErr := s.th.App.CreateJob(s.th.Context, &model.Job{
Type: model.JobTypeExportProcess,
})
s.Require().Nil(appErr)
time.Sleep(time.Millisecond)
err := cancelJobCmdF(c, &cobra.Command{}, []string{job.Id})
s.Require().Nil(err)
s.Require().Empty(printer.GetLines())
s.Require().Empty(printer.GetErrorLines())
// Refresh the job to confirm it was canceled.
job, appErr = s.th.App.GetJob(s.th.Context, job.Id)
s.Require().Nil(appErr)
s.Require().Equal(model.JobStatusCanceled, job.Status)
})
}