diff --git a/server/cmd/mmctl/commands/team.go b/server/cmd/mmctl/commands/team.go index 3586b4ed92..f9ff0be63d 100644 --- a/server/cmd/mmctl/commands/team.go +++ b/server/cmd/mmctl/commands/team.go @@ -178,6 +178,7 @@ func deleteTeam(c client.Client, team *model.Team) (*model.Response, error) { } func archiveTeamsCmdF(c client.Client, cmd *cobra.Command, args []string) error { + var result *multierror.Error confirmFlag, _ := cmd.Flags().GetBool("confirm") if !confirmFlag { if err := getConfirmation("Are you sure you want to archive the specified teams?", true); err != nil { @@ -189,16 +190,18 @@ func archiveTeamsCmdF(c client.Client, cmd *cobra.Command, args []string) error for i, team := range teams { if team == nil { printer.PrintError("Unable to find team '" + args[i] + "'") + result = multierror.Append(result, errors.New("Unable to find team '"+args[i]+"'")) continue } if _, err := c.SoftDeleteTeam(context.TODO(), team.Id); err != nil { printer.PrintError("Unable to archive team '" + team.Name + "' error: " + err.Error()) + result = multierror.Append(result, errors.New("Unable to archive team '"+team.Name+"' error: "+err.Error())) } else { printer.PrintT("Archived team '{{.Name}}'", team) } } - return nil + return result.ErrorOrNil() } func listTeamsCmdF(c client.Client, cmd *cobra.Command, args []string) error { diff --git a/server/cmd/mmctl/commands/team_e2e_test.go b/server/cmd/mmctl/commands/team_e2e_test.go index a865128fb6..4da97a2bd7 100644 --- a/server/cmd/mmctl/commands/team_e2e_test.go +++ b/server/cmd/mmctl/commands/team_e2e_test.go @@ -367,7 +367,7 @@ func (s *MmctlE2ETestSuite) TestArchiveTeamsCmd() { printer.Clean() err := archiveTeamsCmdF(c, cmd, []string{"unknown-team"}) - s.Require().Nil(err) + s.Require().Error(err) s.Require().Len(printer.GetLines(), 0) s.Require().Len(printer.GetErrorLines(), 1) s.Require().Equal("Unable to find team 'unknown-team'", printer.GetErrorLines()[0]) @@ -395,7 +395,7 @@ func (s *MmctlE2ETestSuite) TestArchiveTeamsCmd() { printer.Clean() err := archiveTeamsCmdF(s.th.Client, cmd, []string{s.th.BasicTeam.Name}) - s.Require().Nil(err) + s.Require().Error(err) s.Require().Len(printer.GetLines(), 0) s.Require().Len(printer.GetErrorLines(), 1) s.Require().Contains(printer.GetErrorLines()[0], "You do not have the appropriate permissions.")