comment_edit_test.go

 1package commands
 2
 3import (
 4	"testing"
 5
 6	"github.com/MichaelMure/git-bug/bug"
 7	"github.com/stretchr/testify/require"
 8)
 9
10func TestCommentEdit(t *testing.T) {
11	const golden = "testdata/comment/edit"
12
13	env, bugID, commentID := newTestEnvAndBugWithComment(t)
14
15	opts := commentEditOptions{
16		message: "this is an altered bug comment",
17	}
18	require.NoError(t, runCommentEdit(env.env, opts, []string{commentID}))
19
20	// TODO: remove this comment and everything between the "snip"
21	//       comments when issue #850 is resolved.
22
23	// ***** snip *****
24	cache, err := env.env.backend.ResolveBugPrefix(bugID)
25	require.NoError(t, err)
26	bu, err := bug.Read(env.env.repo, cache.Id())
27	require.NoError(t, err)
28	for _, op := range bu.Operations() {
29		t.Log("Operation: ", op)
30	}
31	t.Log("Compiled comments: ", bu.Compile().Comments)
32	// ***** snip *****
33
34	require.NoError(t, runComment(env.env, []string{bugID}))
35	requireCommentsEqual(t, golden, env)
36}