Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
sreya committed Oct 25, 2022
commit c542f2e6dc4f4d74b0519aff248f4f5fdccc7f17
3 changes: 2 additions & 1 deletion enterprise/cli/groupcreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

agpl "github.com/coder/coder/cli"
"github.com/coder/coder/cli/cliflag"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/codersdk"
)

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

_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Successfully created group %s", group.Name)
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Successfully created group %s!\n", cliui.Styles.Keyword.Render(group.Name))
return nil
},
}
Expand Down
16 changes: 14 additions & 2 deletions enterprise/cli/groupcreate_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package cli_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"

"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/enterprise/cli"
"github.com/coder/coder/enterprise/coderd/coderdenttest"
"github.com/coder/coder/pty/ptytest"
)

func TestCreateGroup(t *testing.T) {
Expand All @@ -15,22 +20,29 @@ func TestCreateGroup(t *testing.T) {
t.Run("OK", func(t *testing.T) {
t.Parallel()

client := coderdtest.New(t, nil)
client := coderdenttest.New(t, nil)
coderdtest.CreateFirstUser(t, client)
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
TemplateRBAC: true,
})

var (
groupName = "test"
avatarURL = "https://example.com"
)

cmd, root := clitest.New(t, "groups",
cmd, root := clitest.NewWithSubcommands(t, cli.EnterpriseSubcommands(), "groups",
"create", groupName,
"--avatar-url", avatarURL,
)

pty := ptytest.New(t)
cmd.SetOut(pty.Output())
clitest.SetupConfig(t, client, root)

err := cmd.Execute()
require.NoError(t, err)

pty.ExpectMatch(fmt.Sprintf("Successfully created group %s!", cliui.Styles.Keyword.Render(groupName)))
})
}
2 changes: 1 addition & 1 deletion enterprise/cli/groupedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func groupEdit() *cobra.Command {
)
cmd := &cobra.Command{
Use: "edit <name>",
Short: "Edit a user group.",
Short: "Edit a user group",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var (
Expand Down
2 changes: 1 addition & 1 deletion enterprise/cli/grouplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func groupList() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "List user groups.",
Short: "List user groups",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
var (
Expand Down