forked from
tangled.org/core
Monorepo for Tangled
1package pulls
2
3import "testing"
4
5func TestNormalizeAutoPullBodyTrailers(t *testing.T) {
6 tests := []struct {
7 name string
8 input string
9 want string
10 }{
11 {
12 name: "trailing trailers are normalized",
13 input: "This is a placeholder commit message with multiple paragraphs\n\nThe content does not matter.\n\nCo-authored-by: Developer One <dev1@example.com>\nReviewed-by: Reviewer Two <reviewer@example.com>\nTicket: PROJ-123\n",
14 want: "This is a placeholder commit message with multiple paragraphs\n\nThe content does not matter.\n\nCo-authored-by: Developer One <dev1@example.com> \nReviewed-by: Reviewer Two <reviewer@example.com> \nTicket: PROJ-123",
15 },
16 {
17 name: "regular prose with colons is unchanged",
18 input: "Body\n\nThis line: has extra words and should not match\nsecond plain line",
19 want: "Body\n\nThis line: has extra words and should not match\nsecond plain line",
20 },
21 {
22 name: "no blank line separator means unchanged",
23 input: "Body\nTicket: PROJ-123",
24 want: "Body\nTicket: PROJ-123",
25 },
26 {
27 name: "trailer continuation line is normalized",
28 input: "Body\n\nReviewed-by: Reviewer\n\tAdditional context\nTicket: PROJ-123\n",
29 want: "Body\n\nReviewed-by: Reviewer \n\tAdditional context \nTicket: PROJ-123",
30 },
31 }
32
33 for _, tt := range tests {
34 t.Run(tt.name, func(t *testing.T) {
35 got := normalizeAutoPullBodyTrailers(tt.input)
36 if got != tt.want {
37 t.Fatalf("normalized body = %q, want %q", got, tt.want)
38 }
39 })
40 }
41}