-
Notifications
You must be signed in to change notification settings - Fork 318
/
message_test.go
42 lines (40 loc) · 994 Bytes
/
message_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package git
import (
"fmt"
"reflect"
"testing"
)
func TestTrailers(t *testing.T) {
t.Parallel()
tests := []struct {
input string
expected []Trailer
}{
{
"commit with zero trailers\n",
[]Trailer{},
},
{
"commit with one trailer\n\nCo-authored-by: Alice <[email protected]>\n",
[]Trailer{
Trailer{Key: "Co-authored-by", Value: "Alice <[email protected]>"},
},
},
{
"commit with two trailers\n\nCo-authored-by: Alice <[email protected]>\nSigned-off-by: Bob <[email protected]>\n",
[]Trailer{
Trailer{Key: "Co-authored-by", Value: "Alice <[email protected]>"},
Trailer{Key: "Signed-off-by", Value: "Bob <[email protected]>"}},
},
}
for _, test := range tests {
fmt.Printf("%s", test.input)
actual, err := MessageTrailers(test.input)
if err != nil {
t.Errorf("Trailers returned an unexpected error: %v", err)
}
if !reflect.DeepEqual(test.expected, actual) {
t.Errorf("expecting %#v\ngot %#v", test.expected, actual)
}
}
}