(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestTrailers(t *testing.T) { |
| 10 | t.Parallel() |
| 11 | tests := []struct { |
| 12 | input string |
| 13 | expected []Trailer |
| 14 | }{ |
| 15 | { |
| 16 | "commit with zero trailers\n", |
| 17 | []Trailer{}, |
| 18 | }, |
| 19 | { |
| 20 | "commit with one trailer\n\nCo-authored-by: Alice <alice@example.com>\n", |
| 21 | []Trailer{ |
| 22 | Trailer{Key: "Co-authored-by", Value: "Alice <alice@example.com>"}, |
| 23 | }, |
| 24 | }, |
| 25 | { |
| 26 | "commit with two trailers\n\nCo-authored-by: Alice <alice@example.com>\nSigned-off-by: Bob <bob@example.com>\n", |
| 27 | []Trailer{ |
| 28 | Trailer{Key: "Co-authored-by", Value: "Alice <alice@example.com>"}, |
| 29 | Trailer{Key: "Signed-off-by", Value: "Bob <bob@example.com>"}}, |
| 30 | }, |
| 31 | } |
| 32 | for _, test := range tests { |
| 33 | fmt.Printf("%s", test.input) |
| 34 | actual, err := MessageTrailers(test.input) |
| 35 | if err != nil { |
| 36 | t.Errorf("Trailers returned an unexpected error: %v", err) |
| 37 | } |
| 38 | if !reflect.DeepEqual(test.expected, actual) { |
| 39 | t.Errorf("expecting %#v\ngot %#v", test.expected, actual) |
| 40 | } |
| 41 | } |
| 42 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…