Skip to content

Commit 499cc7a

Browse files
committed
rename token to session (more flexibility) and add a test
1 parent 64fc965 commit 499cc7a

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ func Root() *cobra.Command {
124124
resetPassword(),
125125
schedules(),
126126
server(),
127+
session(),
127128
show(),
128129
ssh(),
129130
start(),
130131
state(),
131132
stop(),
132133
templates(),
133-
token(),
134134
update(),
135135
users(),
136136
versionCmd(),

cli/token.go renamed to cli/session.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"github.com/coder/coder/cli/cliui"
1010
)
1111

12-
func token() *cobra.Command {
12+
func session() *cobra.Command {
1313
return &cobra.Command{
14-
Use: "token",
14+
Use: "session",
1515
RunE: func(cmd *cobra.Command, args []string) error {
1616
client, err := createClient(cmd)
1717
if err != nil {

cli/session_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package cli_test
2+
3+
import (
4+
"bytes"
5+
"testing"
6+
7+
"github.com/stretchr/testify/require"
8+
9+
"github.com/coder/coder/cli/clitest"
10+
"github.com/coder/coder/coderd/coderdtest"
11+
)
12+
13+
func TestSession(t *testing.T) {
14+
t.Parallel()
15+
t.Run("Session", func(t *testing.T) {
16+
t.Parallel()
17+
18+
client := coderdtest.New(t, nil)
19+
_ = coderdtest.CreateFirstUser(t, client)
20+
cmd, root := clitest.New(t, "session")
21+
clitest.SetupConfig(t, client, root)
22+
buf := new(bytes.Buffer)
23+
cmd.SetOut(buf)
24+
err := cmd.Execute()
25+
require.NoError(t, err)
26+
27+
require.Contains(t, buf.String(), client.SessionToken, "has session token")
28+
})
29+
}

0 commit comments

Comments
 (0)