aboutsummaryrefslogtreecommitdiffstats
path: root/commands/user_create_test.go
blob: 08958344fad1ee520c9183b2c84e1bb8116f39ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package commands

import (
	"strings"
	"testing"

	"github.com/stretchr/testify/require"
)

const (
	testUserName  = "John Doe"
	testUserEmail = "jdoe@example.com"
)

func newTestEnvAndUser(t *testing.T) (*testEnv, string) {
	t.Helper()

	testEnv := newTestEnv(t)

	opts := createUserOptions{
		name:           testUserName,
		email:          testUserEmail,
		avatarURL:      "",
		nonInteractive: true,
	}

	require.NoError(t, runUserCreate(testEnv.env, opts))

	userID := strings.TrimSpace(testEnv.out.String())
	testEnv.out.Reset()

	return testEnv, userID
}

func TestUserCreateCommand(t *testing.T) {
	_, userID := newTestEnvAndUser(t)
	require.Regexp(t, "[0-9a-f]{64}", userID)
}