aboutsummaryrefslogtreecommitdiffstats
path: root/packfile/objects_test.go
blob: 93c348bd1c47670f42e4014d2628720a5710510f (plain) (blame)
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
43
44
45
46
47
48
49
50
package packfile

import (
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
)

func TestSignature(t *testing.T) {
	cases := map[string]Signature{
		`Foo Bar <foo@bar.com> 1257894000 +0100`: {
			Name:  "Foo Bar",
			Email: "foo@bar.com",
			When:  time.Unix(1257894000, 0),
		},
		`Foo Bar <> 1257894000 +0100`: {
			Name:  "Foo Bar",
			Email: "",
			When:  time.Unix(1257894000, 0),
		},
		` <> 1257894000`: {
			Name:  "",
			Email: "",
			When:  time.Unix(1257894000, 0),
		},
		`Foo Bar <foo@bar.com>`: {
			Name:  "Foo Bar",
			Email: "foo@bar.com",
			When:  time.Time{},
		},
		``: {
			Name:  "",
			Email: "",
			When:  time.Time{},
		},
		`<`: {
			Name:  "",
			Email: "",
			When:  time.Time{},
		},
	}

	for raw, exp := range cases {
		got := NewSignature([]byte(raw))
		assert.Equal(t, exp.Name, got.Name)
		assert.Equal(t, exp.Email, got.Email)
		assert.Equal(t, exp.When.Unix(), got.When.Unix())
	}
}