-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit_info_test.go
67 lines (49 loc) · 1.73 KB
/
commit_info_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package gogit
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/yyle88/neatjson/neatjsons"
"github.com/yyle88/syntaxgo"
"github.com/yyle88/syntaxgo/syntaxgo_reflect"
)
func TestCommitInfo_GetCommitMessage(t *testing.T) {
commitInfo := CommitInfo{Message: "example"}
require.Equal(t, "example", commitInfo.BuildCommitMessage())
}
func TestCommitInfo_GetSignatureInfo(t *testing.T) {
commitInfo := CommitInfo{
Name: "John Doe",
Eddress: "[email protected]",
}
objectSignature := commitInfo.GetObjectSignature()
require.Equal(t, "John Doe", objectSignature.Name)
require.Equal(t, "[email protected]", objectSignature.Email)
t.Log(neatjsons.S(objectSignature))
}
func TestPackageName(t *testing.T) {
require.Equal(t, packageName, syntaxgo.CurrentPackageName())
}
func TestPackagePath(t *testing.T) {
require.Equal(t, packagePath, syntaxgo_reflect.GetPkgPathV4(&CommitInfo{}))
}
func TestCommitInfo_CheckFullMessage(t *testing.T) {
commitInfo := CommitInfo{
Name: "Jane Doe",
Eddress: "[email protected]",
Message: "example",
}
objectSignature := commitInfo.GetObjectSignature()
require.Equal(t, "Jane Doe", objectSignature.Name)
require.Equal(t, "[email protected]", objectSignature.Email)
require.Equal(t, "example", commitInfo.BuildCommitMessage())
t.Log(neatjsons.S(objectSignature))
}
func TestCommitInfo_CheckNoneMessage(t *testing.T) {
commitInfo := CommitInfo{}
t.Log(commitInfo.BuildCommitMessage())
objectSignature := commitInfo.GetObjectSignature()
require.Equal(t, "gogit", objectSignature.Name)
require.Equal(t, "[email protected]/go-xlan/gogit", objectSignature.Email)
require.Contains(t, commitInfo.BuildCommitMessage(), packagePath)
t.Log(neatjsons.S(objectSignature))
}