aboutsummaryrefslogtreecommitdiffstats
path: root/commands/add_test.go
blob: 077995a6df5f5f9c2f8de37c4830fb6743671e89 (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
package commands

import (
	"strings"
	"testing"

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

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

	testEnv, _ := newTestEnvAndUser(t)
	opts := addOptions{
		title:          "this is a bug title",
		message:        "this is a bug message",
		messageFile:    "",
		nonInteractive: true,
	}

	require.NoError(t, runAdd(testEnv.env, opts))
	require.Regexp(t, "^[0-9A-Fa-f]{7} created\n$", testEnv.out)
	bugID := strings.Split(testEnv.out.String(), " ")[0]
	testEnv.out.Reset()

	return testEnv, bugID
}

func TestAdd(t *testing.T) {
	_, bugID := newTestEnvAndBug(t)
	require.Regexp(t, "^[0-9A-Fa-f]{7}$", bugID)
}