-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgogit_test.go
83 lines (64 loc) · 1.93 KB
/
gogit_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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package gogit_test
import (
"testing"
"github.com/go-xlan/gogit"
"github.com/go-xlan/gogit/gogitassist"
"github.com/stretchr/testify/require"
"github.com/yyle88/neatjson/neatjsons"
"github.com/yyle88/runpath"
)
func TestNew(t *testing.T) {
client, err := gogit.New(runpath.PARENT.Path())
require.NoError(t, err)
gogitassist.DebugRepo(client.Repo())
status, err := client.Status()
require.NoError(t, err)
t.Log(neatjsons.S(status))
}
func TestMustNew(t *testing.T) {
client := gogit.MustNew(runpath.PARENT.Path())
gogitassist.DebugRepo(client.Repo())
status, err := client.Status()
require.NoError(t, err)
t.Log(neatjsons.S(status))
}
func TestClient_CommitAll(t *testing.T) {
client, err := gogit.New(runpath.PARENT.Path())
require.NoError(t, err)
gogitassist.DebugRepo(client.Repo())
if false { //not commit in this test case
err := client.AddAll()
require.NoError(t, err)
status, err := client.Status()
require.NoError(t, err)
t.Log(neatjsons.S(status))
commitHash, err := client.CommitAll(gogit.NewCommitInfo("提交代码"))
require.NoError(t, err)
t.Log(commitHash)
}
}
func TestClient_IsLatestCommitPushedToRemote(t *testing.T) {
client, err := gogit.New(runpath.PARENT.Path())
require.NoError(t, err)
gogitassist.DebugRepo(client.Repo())
matched, err := client.IsLatestCommitPushedToRemote("origin")
require.NoError(t, err)
t.Log(matched)
}
func TestClient_IsLatestCommitPushedToRemote_NotExist(t *testing.T) {
client, err := gogit.New(runpath.PARENT.Path())
require.NoError(t, err)
gogitassist.DebugRepo(client.Repo())
matched, err := client.IsLatestCommitPushedToRemote("origin2")
require.NoError(t, err)
t.Log(matched)
require.False(t, matched)
}
func TestClient_IsLatestCommitPushed(t *testing.T) {
client, err := gogit.New(runpath.PARENT.Path())
require.NoError(t, err)
gogitassist.DebugRepo(client.Repo())
pushed, err := client.IsLatestCommitPushed()
require.NoError(t, err)
t.Log(pushed)
}