-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgogitv5_test.go
66 lines (50 loc) · 1.44 KB
/
gogitv5_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
package gogit_test
import (
"testing"
"github.com/go-xlan/gogit"
"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)
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)
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_IsHashMatchedRemote(t *testing.T) {
client, err := gogit.New(runpath.PARENT.Path())
require.NoError(t, err)
matched, err := client.IsHashMatchedRemote("origin")
require.NoError(t, err)
t.Log(matched)
}
func TestClient_IsHashMatchedRemote_NotExist(t *testing.T) {
client, err := gogit.New(runpath.PARENT.Path())
require.NoError(t, err)
matched, err := client.IsHashMatchedRemote("origin2")
require.NoError(t, err)
t.Log(matched)
}
func TestClient_IsPushedToAnyRemote(t *testing.T) {
client, err := gogit.New(runpath.PARENT.Path())
require.NoError(t, err)
pushed, err := client.IsPushedToAnyRemote()
require.NoError(t, err)
t.Log(pushed)
}