mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: Allow regen-ssh and fetching a single user from the cli (#1619)
* feat: Allow regen-ssh and fetching a single user from the cli
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/cli/clitest"
|
||||
@ -51,3 +53,26 @@ func TestUserList(t *testing.T) {
|
||||
require.Contains(t, err.Error(), "Try logging in using 'coder login <url>'.")
|
||||
})
|
||||
}
|
||||
|
||||
func TestUserShow(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
client := coderdtest.New(t, nil)
|
||||
admin := coderdtest.CreateFirstUser(t, client)
|
||||
other := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID)
|
||||
otherUser, err := other.User(ctx, codersdk.Me)
|
||||
require.NoError(t, err, "fetch other user")
|
||||
cmd, root := clitest.New(t, "users", "show", otherUser.Username)
|
||||
clitest.SetupConfig(t, client, root)
|
||||
doneChan := make(chan struct{})
|
||||
pty := ptytest.New(t)
|
||||
cmd.SetIn(pty.Input())
|
||||
cmd.SetOut(pty.Output())
|
||||
go func() {
|
||||
defer close(doneChan)
|
||||
err := cmd.Execute()
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
pty.ExpectMatch(otherUser.Email)
|
||||
<-doneChan
|
||||
}
|
||||
|
Reference in New Issue
Block a user