-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathsignature_test.go
47 lines (42 loc) · 1.08 KB
/
signature_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
43
44
45
46
47
// Copyright 2020 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package git
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func Test_parseSignature(t *testing.T) {
tests := []struct {
line string
expSig *Signature
}{
{
line: "Patrick Gundlach <[email protected]> 1378823654 +0200",
expSig: &Signature{
Name: "Patrick Gundlach",
Email: "[email protected]",
When: time.Unix(1378823654, 0),
},
}, {
line: "Patrick Gundlach <[email protected]> Tue Sep 10 16:34:14 2013 +0200",
expSig: &Signature{
Name: "Patrick Gundlach",
Email: "[email protected]",
When: time.Unix(1378823654, 0),
},
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
sig, err := parseSignature([]byte(test.line))
if err != nil {
t.Fatal(err)
}
assert.Equal(t, test.expSig.Name, sig.Name)
assert.Equal(t, test.expSig.Email, sig.Email)
assert.Equal(t, test.expSig.When.Unix(), sig.When.Unix())
})
}
}