mirror of https://github.com/coder/coder.git
41 lines
880 B
Go
41 lines
880 B
Go
package cli_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/coder/coder/v2/cli/clitest"
|
|
"github.com/coder/coder/v2/coderd/coderdtest"
|
|
"github.com/coder/coder/v2/pty/ptytest"
|
|
)
|
|
|
|
func TestUserCreate(t *testing.T) {
|
|
t.Parallel()
|
|
t.Run("Prompts", func(t *testing.T) {
|
|
t.Parallel()
|
|
client := coderdtest.New(t, nil)
|
|
coderdtest.CreateFirstUser(t, client)
|
|
inv, root := clitest.New(t, "users", "create")
|
|
clitest.SetupConfig(t, client, root)
|
|
doneChan := make(chan struct{})
|
|
pty := ptytest.New(t).Attach(inv)
|
|
go func() {
|
|
defer close(doneChan)
|
|
err := inv.Run()
|
|
assert.NoError(t, err)
|
|
}()
|
|
matches := []string{
|
|
"Username", "dean",
|
|
"Email", "dean@coder.com",
|
|
}
|
|
for i := 0; i < len(matches); i += 2 {
|
|
match := matches[i]
|
|
value := matches[i+1]
|
|
pty.ExpectMatch(match)
|
|
pty.WriteLine(value)
|
|
}
|
|
<-doneChan
|
|
})
|
|
}
|