aboutsummaryrefslogtreecommitdiffstats
path: root/bug/comment_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'bug/comment_test.go')
-rw-r--r--bug/comment_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/bug/comment_test.go b/bug/comment_test.go
new file mode 100644
index 00000000..423d10d8
--- /dev/null
+++ b/bug/comment_test.go
@@ -0,0 +1,27 @@
+package bug
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/MichaelMure/git-bug/entity"
+)
+
+func TestCommentId(t *testing.T) {
+ bugId := entity.Id("abcdefghijklmnopqrstuvwxyz1234__________")
+ opId := entity.Id("ABCDEFGHIJ______________________________")
+ expectedId := entity.Id("aAbBcCdefDghijEklmnFopqrGstuvHwxyzI1234J")
+
+ mergedId := DeriveCommentId(bugId, opId)
+ require.Equal(t, expectedId, mergedId)
+
+ // full length
+ splitBugId, splitCommentId := SplitCommentId(mergedId.String())
+ require.Equal(t, string(bugId[:30]), splitBugId)
+ require.Equal(t, string(opId[:10]), splitCommentId)
+
+ splitBugId, splitCommentId = SplitCommentId(string(expectedId[:6]))
+ require.Equal(t, string(bugId[:3]), splitBugId)
+ require.Equal(t, string(opId[:3]), splitCommentId)
+}