1package commands
 2
 3import (
 4	"strings"
 5	"testing"
 6
 7	"github.com/stretchr/testify/require"
 8)
 9
10func newTestEnvAndBug(t *testing.T) (*testEnv, string) {
11	t.Helper()
12
13	testEnv, _ := newTestEnvAndUser(t)
14	opts := addOptions{
15		title:          "this is a bug title",
16		message:        "this is a bug message",
17		messageFile:    "",
18		nonInteractive: true,
19	}
20
21	require.NoError(t, runAdd(testEnv.env, opts))
22	require.Regexp(t, "^[0-9A-Fa-f]{7} created\n$", testEnv.out)
23	bugID := strings.Split(testEnv.out.String(), " ")[0]
24	testEnv.out.Reset()
25
26	return testEnv, bugID
27}
28
29func TestAdd(t *testing.T) {
30	_, bugID := newTestEnvAndBug(t)
31	require.Regexp(t, "^[0-9A-Fa-f]{7}$", bugID)
32}