Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Fixes #13399 : Add unit tests to the "TeamGroupStatusCmd" mmctl comma…
Browse files Browse the repository at this point in the history
…nd (#89)

* init

* Added tests for checking team group status command

* para pharasing tests names
  • Loading branch information
M-ZubairAhmed authored and jespino committed Jan 9, 2020
1 parent 9193f05 commit 339327e
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 2 deletions.
96 changes: 96 additions & 0 deletions commands/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
}
3 changes: 1 addition & 2 deletions docs/mmctl_user_email.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ mmctl user email [user] [new email] [flags]
### Examples

```
user email test [email protected]
user activate username
user email testuser [email protected]
```

### Options
Expand Down

0 comments on commit 339327e

Please sign in to comment.