diff options
author | Steve Moyer <smoyer1@selesy.com> | 2022-05-28 10:30:44 -0400 |
---|---|---|
committer | Steve Moyer <smoyer1@selesy.com> | 2022-05-28 10:30:44 -0400 |
commit | ecfffe3902731224288add3b44119dccae46fd6f (patch) | |
tree | abd59343b04b2f2c40702441724a1b214b453ce8 | |
parent | 508d0eb82a8a29cc814e87d11f7ee0959cb137ab (diff) | |
download | git-bug-ecfffe3902731224288add3b44119dccae46fd6f.tar.gz |
test(778): execute add user in testEnv and return userID
-rw-r--r-- | commands/add_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/commands/add_test.go b/commands/add_test.go new file mode 100644 index 00000000..b85c7fa2 --- /dev/null +++ b/commands/add_test.go @@ -0,0 +1,33 @@ +package commands_test + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +func newTestEnvUserAndBug(t *testing.T) (*testEnv, string, string) { + t.Helper() + + testEnv, userID := newTestEnvAndUser(t) + + testEnv.cmd.SetArgs([]string{ + "add", + "--non-interactive", + "-t 'this is a bug title'", + "-m 'this is a bug message'", + }) + + testEnv.Execute(t) + require.Regexp(t, "^[0-9A-Fa-f]{7} created\n$", testEnv.out) + bugID := strings.Split(testEnv.out.String(), " ")[0] + testEnv.out.Reset() + + return testEnv, userID, bugID +} + +func TestAdd(t *testing.T) { + _, _, user := newTestEnvUserAndBug(t) + require.Regexp(t, "^[0-9A-Fa-f]{7}$", user) +} |