From 50324b8a7c23d5f68246af05e59024278e199148 Mon Sep 17 00:00:00 2001 From: Steve Moyer Date: Fri, 27 May 2022 13:39:16 -0400 Subject: test(778): verify user create results in an identity and cache --- commands/user_create_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 commands/user_create_test.go (limited to 'commands/user_create_test.go') diff --git a/commands/user_create_test.go b/commands/user_create_test.go new file mode 100644 index 00000000..c2e2398f --- /dev/null +++ b/commands/user_create_test.go @@ -0,0 +1,37 @@ +package commands_test + +import ( + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +func newTestEnvAndUser(t *testing.T) (*testEnv, string) { + t.Helper() + + testEnv := newTestEnv(t) + + testEnv.cmd.SetArgs( + []string{ + "user", + "create", + "--non-interactive", + "-n John Doe", + "-e jdoe@example.com", + }) + + testEnv.Execute(t) + + return testEnv, strings.TrimSpace(testEnv.out.String()) +} + +func TestUserCreateCommand(t *testing.T) { + testEnv, userID := newTestEnvAndUser(t) + + t.Log("CWD:", testEnv.cwd) + + require.FileExists(t, filepath.Join(testEnv.cwd, ".git", "refs", "identities", userID)) + require.FileExists(t, filepath.Join(testEnv.cwd, ".git", "git-bug", "identity-cache")) +} -- cgit From 508d0eb82a8a29cc814e87d11f7ee0959cb137ab Mon Sep 17 00:00:00 2001 From: Steve Moyer Date: Sat, 28 May 2022 10:29:30 -0400 Subject: test(778): clear output after user creation --- commands/user_create_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'commands/user_create_test.go') diff --git a/commands/user_create_test.go b/commands/user_create_test.go index c2e2398f..07ed657b 100644 --- a/commands/user_create_test.go +++ b/commands/user_create_test.go @@ -23,8 +23,10 @@ func newTestEnvAndUser(t *testing.T) (*testEnv, string) { }) testEnv.Execute(t) + userID := strings.TrimSpace(testEnv.out.String()) + testEnv.out.Reset() - return testEnv, strings.TrimSpace(testEnv.out.String()) + return testEnv, userID } func TestUserCreateCommand(t *testing.T) { -- cgit From 0a9aaa94429172d14297f709ec2137cd3749cfea Mon Sep 17 00:00:00 2001 From: Steve Moyer Date: Wed, 15 Jun 2022 09:07:00 -0400 Subject: refactor(778): test only command implementations --- commands/user_create_test.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'commands/user_create_test.go') diff --git a/commands/user_create_test.go b/commands/user_create_test.go index 07ed657b..223e7ec3 100644 --- a/commands/user_create_test.go +++ b/commands/user_create_test.go @@ -1,4 +1,4 @@ -package commands_test +package commands import ( "path/filepath" @@ -13,16 +13,15 @@ func newTestEnvAndUser(t *testing.T) (*testEnv, string) { testEnv := newTestEnv(t) - testEnv.cmd.SetArgs( - []string{ - "user", - "create", - "--non-interactive", - "-n John Doe", - "-e jdoe@example.com", - }) + opts := createUserOptions{ + name: "John Doe", + email: "jdoe@example.com", + avatarURL: "", + nonInteractive: true, + } + + require.NoError(t, runUserCreate(testEnv.env, opts)) - testEnv.Execute(t) userID := strings.TrimSpace(testEnv.out.String()) testEnv.out.Reset() @@ -32,8 +31,6 @@ func newTestEnvAndUser(t *testing.T) (*testEnv, string) { func TestUserCreateCommand(t *testing.T) { testEnv, userID := newTestEnvAndUser(t) - t.Log("CWD:", testEnv.cwd) - require.FileExists(t, filepath.Join(testEnv.cwd, ".git", "refs", "identities", userID)) require.FileExists(t, filepath.Join(testEnv.cwd, ".git", "git-bug", "identity-cache")) } -- cgit