From 339327e2a84b169c0cabf48612cc8dec496a96ac Mon Sep 17 00:00:00 2001 From: Md Zubair Ahmed Date: Thu, 9 Jan 2020 09:20:16 +0000 Subject: [PATCH] Fixes #13399 : Add unit tests to the "TeamGroupStatusCmd" mmctl command (#89) * init * Added tests for checking team group status command * para pharasing tests names --- commands/group_test.go | 96 ++++++++++++++++++++++++++++++++++++++++ docs/mmctl_user_email.md | 3 +- 2 files changed, 97 insertions(+), 2 deletions(-) diff --git a/commands/group_test.go b/commands/group_test.go index 83341a7c8..9d6f28707 100644 --- a/commands/group_test.go +++ b/commands/group_test.go @@ -272,3 +272,99 @@ func (s *MmctlUnitTestSuite) TestTeamGroupListCmd() { s.Require().Equal(printer.GetLines()[1], &group2) }) } + +func (s *MmctlUnitTestSuite) TestTeamGroupStatusCmd() { + s.Run("Should fail when team is not found", func() { + printer.Clean() + + teamID := "teamId" + arg := teamID + args := []string{arg} + cmd := &cobra.Command{} + + s.client. + EXPECT(). + GetTeam(teamID, ""). + Return(nil, &model.Response{Error: nil}). + Times(1) + + s.client. + EXPECT(). + GetTeamByName(teamID, ""). + Return(nil, &model.Response{Error: nil}). + Times(1) + + err := teamGroupStatusCmdF(s.client, cmd, args) + + s.Require().EqualError(err, "Unable to find team '"+args[0]+"'") + }) + + s.Run("Should show valid response when group constraints status for a team is not present", func() { + printer.Clean() + + teamID := "teamId" + arg := teamID + args := []string{arg} + cmd := &cobra.Command{} + team := &model.Team{Id: teamID} + + s.client. + EXPECT(). + GetTeam(teamID, ""). + Return(team, &model.Response{Error: nil}). + Times(1) + + err := teamGroupStatusCmdF(s.client, cmd, args) + + s.Require().Nil(err) + s.Require().Len(printer.GetErrorLines(), 0) + s.Require().Len(printer.GetLines(), 1) + s.Require().Equal(printer.GetLines()[0], "Disabled") + }) + + s.Run("Should show valid response when group constraints status for a team is enabled", func() { + printer.Clean() + + teamID := "teamId" + arg := teamID + args := []string{arg} + cmd := &cobra.Command{} + team := &model.Team{Id: teamID, GroupConstrained: model.NewBool(true)} + + s.client. + EXPECT(). + GetTeam(teamID, ""). + Return(team, &model.Response{Error: nil}). + Times(1) + + err := teamGroupStatusCmdF(s.client, cmd, args) + + s.Require().Nil(err) + s.Require().Len(printer.GetErrorLines(), 0) + s.Require().Len(printer.GetLines(), 1) + s.Require().Equal(printer.GetLines()[0], "Enabled") + }) + + s.Run("Should show valid response when group constraints status for a team is disabled", func() { + printer.Clean() + + teamID := "teamId" + arg := teamID + args := []string{arg} + cmd := &cobra.Command{} + team := &model.Team{Id: teamID, GroupConstrained: model.NewBool(false)} + + s.client. + EXPECT(). + GetTeam(teamID, ""). + Return(team, &model.Response{Error: nil}). + Times(1) + + err := teamGroupStatusCmdF(s.client, cmd, args) + + s.Require().Nil(err) + s.Require().Len(printer.GetErrorLines(), 0) + s.Require().Len(printer.GetLines(), 1) + s.Require().Equal(printer.GetLines()[0], "Disabled") + }) +} diff --git a/docs/mmctl_user_email.md b/docs/mmctl_user_email.md index 71b3f3d15..e531d8633 100644 --- a/docs/mmctl_user_email.md +++ b/docs/mmctl_user_email.md @@ -13,8 +13,7 @@ mmctl user email [user] [new email] [flags] ### Examples ``` - user email test user@example.com - user activate username + user email testuser user@example.com ``` ### Options