@@ -65,3 +65,28 @@ func Test_expandDefaultMergeMessage(t *testing.T) {
6565 })
6666 }
6767}
68+
69+ func TestAddCommitMessageTailer (t * testing.T ) {
70+ // add tailer for empty message
71+ assert .Equal (t , "\n \n Test-tailer: TestValue" , AddCommitMessageTailer ("" , "Test-tailer" , "TestValue" ))
72+
73+ // add tailer for message without newlines
74+ assert .Equal (t , "title\n \n Test-tailer: TestValue" , AddCommitMessageTailer ("title" , "Test-tailer" , "TestValue" ))
75+ assert .Equal (t , "title\n \n Not tailer: xxx\n \n Test-tailer: TestValue" , AddCommitMessageTailer ("title\n \n Not tailer: xxx" , "Test-tailer" , "TestValue" ))
76+ assert .Equal (t , "title\n \n NotTailer: xxx\n \n Test-tailer: TestValue" , AddCommitMessageTailer ("title\n \n NotTailer: xxx" , "Test-tailer" , "TestValue" ))
77+ assert .Equal (t , "title\n \n not-tailer: xxx\n \n Test-tailer: TestValue" , AddCommitMessageTailer ("title\n \n not-tailer: xxx" , "Test-tailer" , "TestValue" ))
78+
79+ // add tailer for message with one EOL
80+ assert .Equal (t , "title\n \n Test-tailer: TestValue" , AddCommitMessageTailer ("title\n " , "Test-tailer" , "TestValue" ))
81+
82+ // add tailer for message with two EOLs
83+ assert .Equal (t , "title\n \n Test-tailer: TestValue" , AddCommitMessageTailer ("title\n \n " , "Test-tailer" , "TestValue" ))
84+
85+ // add tailer for message with existing tailer (won't duplicate)
86+ assert .Equal (t , "title\n \n Test-tailer: TestValue" , AddCommitMessageTailer ("title\n \n Test-tailer: TestValue" , "Test-tailer" , "TestValue" ))
87+ assert .Equal (t , "title\n \n Test-tailer: TestValue\n " , AddCommitMessageTailer ("title\n \n Test-tailer: TestValue\n " , "Test-tailer" , "TestValue" ))
88+
89+ // add tailer for message with existing tailer and different value (will append)
90+ assert .Equal (t , "title\n \n Test-tailer: v1\n Test-tailer: v2" , AddCommitMessageTailer ("title\n \n Test-tailer: v1" , "Test-tailer" , "v2" ))
91+ assert .Equal (t , "title\n \n Test-tailer: v1\n Test-tailer: v2" , AddCommitMessageTailer ("title\n \n Test-tailer: v1\n " , "Test-tailer" , "v2" ))
92+ }
0 commit comments