comment_test.go

 1package bug
 2
 3import (
 4	"testing"
 5
 6	"github.com/stretchr/testify/require"
 7
 8	"github.com/MichaelMure/git-bug/entity"
 9)
10
11func TestCommentId(t *testing.T) {
12	bugId := entity.Id("abcdefghijklmnopqrstuvwxyz1234__________")
13	opId := entity.Id("ABCDEFGHIJ______________________________")
14	expectedId := entity.Id("aAbBcCdefDghijEklmnFopqrGstuvHwxyzI1234J")
15
16	mergedId := DeriveCommentId(bugId, opId)
17	require.Equal(t, expectedId, mergedId)
18
19	// full length
20	splitBugId, splitCommentId := SplitCommentId(mergedId.String())
21	require.Equal(t, string(bugId[:30]), splitBugId)
22	require.Equal(t, string(opId[:10]), splitCommentId)
23
24	splitBugId, splitCommentId = SplitCommentId(string(expectedId[:6]))
25	require.Equal(t, string(bugId[:3]), splitBugId)
26	require.Equal(t, string(opId[:3]), splitCommentId)
27}