git-module

git clone git://git.lin.moe/fork/git-module.git

 1package git
 2
 3import (
 4	"testing"
 5	"time"
 6
 7	"github.com/stretchr/testify/assert"
 8)
 9
10func Test_parseSignature(t *testing.T) {
11	tests := []struct {
12		line   string
13		expSig *Signature
14	}{
15		{
16			line: "Patrick Gundlach <gundlach@speedata.de> 1378823654 +0200",
17			expSig: &Signature{
18				Name:  "Patrick Gundlach",
19				Email: "gundlach@speedata.de",
20				When:  time.Unix(1378823654, 0),
21			},
22		}, {
23			line: "Patrick Gundlach <gundlach@speedata.de> Tue Sep 10 16:34:14 2013 +0200",
24			expSig: &Signature{
25				Name:  "Patrick Gundlach",
26				Email: "gundlach@speedata.de",
27				When:  time.Unix(1378823654, 0),
28			},
29		},
30	}
31	for _, test := range tests {
32		t.Run("", func(t *testing.T) {
33			sig, err := parseSignature([]byte(test.line))
34			if err != nil {
35				t.Fatal(err)
36			}
37
38			assert.Equal(t, test.expSig.Name, sig.Name)
39			assert.Equal(t, test.expSig.Email, sig.Email)
40			assert.Equal(t, test.expSig.When.Unix(), sig.When.Unix())
41		})
42	}
43}