summaryrefslogtreecommitdiff
path: root/message_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'message_test.go')
-rw-r--r--message_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/message_test.go b/message_test.go
new file mode 100644
index 0000000..f33ccb7
--- /dev/null
+++ b/message_test.go
@@ -0,0 +1,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)
+ }
+ }
+}