Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c542f2e

Browse files
committedOct 25, 2022
fix tests
1 parent 728c7a4 commit c542f2e

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed
 

‎enterprise/cli/groupcreate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
agpl "github.com/coder/coder/cli"
1010
"github.com/coder/coder/cli/cliflag"
11+
"github.com/coder/coder/cli/cliui"
1112
"github.com/coder/coder/codersdk"
1213
)
1314

@@ -42,7 +43,7 @@ func groupCreate() *cobra.Command {
4243
return xerrors.Errorf("create group: %w", err)
4344
}
4445

45-
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Successfully created group %s", group.Name)
46+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Successfully created group %s!\n", cliui.Styles.Keyword.Render(group.Name))
4647
return nil
4748
},
4849
}

‎enterprise/cli/groupcreate_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package cli_test
22

33
import (
4+
"fmt"
45
"testing"
56

67
"github.com/stretchr/testify/require"
78

89
"github.com/coder/coder/cli/clitest"
10+
"github.com/coder/coder/cli/cliui"
911
"github.com/coder/coder/coderd/coderdtest"
12+
"github.com/coder/coder/enterprise/cli"
13+
"github.com/coder/coder/enterprise/coderd/coderdenttest"
14+
"github.com/coder/coder/pty/ptytest"
1015
)
1116

1217
func TestCreateGroup(t *testing.T) {
@@ -15,22 +20,29 @@ func TestCreateGroup(t *testing.T) {
1520
t.Run("OK", func(t *testing.T) {
1621
t.Parallel()
1722

18-
client := coderdtest.New(t, nil)
23+
client := coderdenttest.New(t, nil)
1924
coderdtest.CreateFirstUser(t, client)
25+
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
26+
TemplateRBAC: true,
27+
})
2028

2129
var (
2230
groupName = "test"
2331
avatarURL = "https://example.com"
2432
)
2533

26-
cmd, root := clitest.New(t, "groups",
34+
cmd, root := clitest.NewWithSubcommands(t, cli.EnterpriseSubcommands(), "groups",
2735
"create", groupName,
2836
"--avatar-url", avatarURL,
2937
)
3038

39+
pty := ptytest.New(t)
40+
cmd.SetOut(pty.Output())
3141
clitest.SetupConfig(t, client, root)
3242

3343
err := cmd.Execute()
3444
require.NoError(t, err)
45+
46+
pty.ExpectMatch(fmt.Sprintf("Successfully created group %s!", cliui.Styles.Keyword.Render(groupName)))
3547
})
3648
}

‎enterprise/cli/groupedit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func groupEdit() *cobra.Command {
2323
)
2424
cmd := &cobra.Command{
2525
Use: "edit <name>",
26-
Short: "Edit a user group.",
26+
Short: "Edit a user group",
2727
Args: cobra.ExactArgs(1),
2828
RunE: func(cmd *cobra.Command, args []string) error {
2929
var (

‎enterprise/cli/grouplist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
func groupList() *cobra.Command {
1717
cmd := &cobra.Command{
1818
Use: "list",
19-
Short: "List user groups.",
19+
Short: "List user groups",
2020
Args: cobra.NoArgs,
2121
RunE: func(cmd *cobra.Command, args []string) error {
2222
var (

0 commit comments

Comments
 (0)
Failed to load comments.