Skip to content

Commit 086b226

Browse files
committed
git: add GetDivergingCommits test
1 parent df00cca commit 086b226

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

modules/git/repo_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package git
55

66
import (
7+
"context"
78
"path/filepath"
89
"testing"
910

@@ -29,3 +30,27 @@ func TestRepoIsEmpty(t *testing.T) {
2930
assert.NoError(t, err)
3031
assert.True(t, isEmpty)
3132
}
33+
34+
func TestRepoGetDivergingCommits(t *testing.T) {
35+
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
36+
do, err := GetDivergingCommits(context.Background(), bareRepo1Path, "master", "branch2")
37+
assert.NoError(t, err)
38+
assert.Equal(t, DivergeObject{
39+
Ahead: 1,
40+
Behind: 5,
41+
}, do)
42+
43+
do, err = GetDivergingCommits(context.Background(), bareRepo1Path, "master", "master")
44+
assert.NoError(t, err)
45+
assert.Equal(t, DivergeObject{
46+
Ahead: 0,
47+
Behind: 0,
48+
}, do)
49+
50+
do, err = GetDivergingCommits(context.Background(), bareRepo1Path, "master", "test")
51+
assert.NoError(t, err)
52+
assert.Equal(t, DivergeObject{
53+
Ahead: 0,
54+
Behind: 2,
55+
}, do)
56+
}

0 commit comments

Comments
 (0)