|
5 | 5 | package git |
6 | 6 |
|
7 | 7 | import ( |
8 | | - "path/filepath" |
9 | 8 | "testing" |
10 | 9 |
|
11 | 10 | "github.com/stretchr/testify/assert" |
12 | 11 | ) |
13 | 12 |
|
14 | 13 | func TestCommitsCount(t *testing.T) { |
15 | | - p, err := filepath.Abs("../../") |
| 14 | + // TODO: since drone will only git clone -depth=50, this should be moved to recent commit id |
| 15 | + commitsCount, err := CommitsCount("", "22d3d029e6f7e6359f3a6fbe8b7827b579ac7445") |
16 | 16 | assert.NoError(t, err) |
17 | | - commitsCount, err := CommitsCount(p, "a30e5bcaf83a82f5f7d1c89a6f9f7e52036d74af") |
18 | | - assert.NoError(t, err) |
19 | | - assert.Equal(t, int64(6), commitsCount) |
| 17 | + assert.Equal(t, int64(7287), commitsCount) |
20 | 18 | } |
21 | 19 |
|
22 | 20 | func TestGetFullCommitID(t *testing.T) { |
23 | | - p, err := filepath.Abs("../../") |
24 | | - assert.NoError(t, err) |
25 | | - id, err := GetFullCommitID(p, "a30e5bca") |
| 21 | + id, err := GetFullCommitID("", "22d3d029") |
26 | 22 | assert.NoError(t, err) |
27 | | - assert.Equal(t, "a30e5bcaf83a82f5f7d1c89a6f9f7e52036d74af", id) |
| 23 | + assert.Equal(t, "22d3d029e6f7e6359f3a6fbe8b7827b579ac7445", id) |
28 | 24 | } |
29 | 25 |
|
30 | 26 | func TestGetFullCommitIDError(t *testing.T) { |
31 | | - p, err := filepath.Abs("../../") |
32 | | - assert.NoError(t, err) |
33 | | - id, err := GetFullCommitID(p, "unknown") |
| 27 | + id, err := GetFullCommitID("", "unknown") |
34 | 28 | assert.Empty(t, id) |
35 | 29 | if assert.Error(t, err) { |
36 | 30 | assert.EqualError(t, err, "object does not exist [id: unknown, rel_path: ]") |
|
0 commit comments