1package commands
 2
 3import (
 4	"testing"
 5
 6	"github.com/stretchr/testify/require"
 7)
 8
 9func newTestEnvAndBugWithComment(t *testing.T) (*testEnv, string, string) {
10	t.Helper()
11
12	env, bugID := newTestEnvAndBug(t)
13
14	opts := commentAddOptions{
15		message: "this is a bug comment",
16	}
17	require.NoError(t, runCommentAdd(env.env, opts, []string{bugID}))
18	require.NoError(t, runComment(env.env, []string{bugID}))
19	comments := parseComments(t, env)
20	require.Len(t, comments, 2)
21
22	env.out.Reset()
23
24	return env, bugID, comments[1].id
25}
26
27func TestCommentAdd(t *testing.T) {
28	const golden = "testdata/comment/add"
29
30	env, bugID, _ := newTestEnvAndBugWithComment(t)
31	require.NoError(t, runComment(env.env, []string{bugID}))
32	requireCommentsEqual(t, golden, env)
33}