aboutsummaryrefslogtreecommitdiffstats
path: root/commands/comment_add_test.go
blob: 34ff3743f5dc9d26236a557014024ddd031c6067 (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
33
package commands

import (
	"testing"

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

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

	env, bugID := newTestEnvAndBug(t)

	opts := commentAddOptions{
		message: "this is a bug comment",
	}
	require.NoError(t, runCommentAdd(env.env, opts, []string{bugID}))
	require.NoError(t, runComment(env.env, []string{bugID}))
	comments := parseComments(t, env)
	require.Len(t, comments, 2)

	env.out.Reset()

	return env, bugID, comments[1].id
}

func TestCommentAdd(t *testing.T) {
	const golden = "testdata/comment/add"

	env, bugID, _ := newTestEnvAndBugWithComment(t)
	require.NoError(t, runComment(env.env, []string{bugID}))
	requireCommentsEqual(t, golden, env)
}