summaryrefslogtreecommitdiffstats
path: root/modules/git/commit_info_test.go
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2019-07-22 14:03:15 +0200
committerLauris BH <lauris@nix.lv>2019-07-22 15:03:15 +0300
commitfe7689a6b28b644ef309350cf01f563201f44d10 (patch)
tree7d5d5ff94892be59e56eb7d4d59fcadf40e5ff96 /modules/git/commit_info_test.go
parentb0cd3b8ab9b174f11fd4db8737106be5caf9cc1c (diff)
downloadgitea-fe7689a6b28b644ef309350cf01f563201f44d10.tar.gz
gitea-fe7689a6b28b644ef309350cf01f563201f44d10.zip
Fix empty commits now showing in repo overview (#7521)
* Fix empty commits now showing in repo overview * add test * make fmt
Diffstat (limited to 'modules/git/commit_info_test.go')
-rw-r--r--modules/git/commit_info_test.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/modules/git/commit_info_test.go b/modules/git/commit_info_test.go
index d7d863b032..71637d188a 100644
--- a/modules/git/commit_info_test.go
+++ b/modules/git/commit_info_test.go
@@ -28,21 +28,27 @@ func cloneRepo(url, dir, name string) (string, error) {
func testGetCommitsInfo(t *testing.T, repo1 *Repository) {
// these test case are specific to the repo1 test repo
testCases := []struct {
- CommitID string
- Path string
- ExpectedIDs map[string]string
+ CommitID string
+ Path string
+ ExpectedIDs map[string]string
+ ExpectedTreeCommit string
}{
{"8d92fc957a4d7cfd98bc375f0b7bb189a0d6c9f2", "", map[string]string{
"file1.txt": "95bb4d39648ee7e325106df01a621c530863a653",
"file2.txt": "8d92fc957a4d7cfd98bc375f0b7bb189a0d6c9f2",
- }},
+ }, "8d92fc957a4d7cfd98bc375f0b7bb189a0d6c9f2"},
{"2839944139e0de9737a044f78b0e4b40d989a9e3", "", map[string]string{
"file1.txt": "2839944139e0de9737a044f78b0e4b40d989a9e3",
"branch1.txt": "9c9aef8dd84e02bc7ec12641deb4c930a7c30185",
- }},
+ }, "2839944139e0de9737a044f78b0e4b40d989a9e3"},
{"5c80b0245c1c6f8343fa418ec374b13b5d4ee658", "branch2", map[string]string{
"branch2.txt": "5c80b0245c1c6f8343fa418ec374b13b5d4ee658",
- }},
+ }, "5c80b0245c1c6f8343fa418ec374b13b5d4ee658"},
+ {"feaf4ba6bc635fec442f46ddd4512416ec43c2c2", "", map[string]string{
+ "file1.txt": "95bb4d39648ee7e325106df01a621c530863a653",
+ "file2.txt": "8d92fc957a4d7cfd98bc375f0b7bb189a0d6c9f2",
+ "foo": "37991dec2c8e592043f47155ce4808d4580f9123",
+ }, "feaf4ba6bc635fec442f46ddd4512416ec43c2c2"},
}
for _, testCase := range testCases {
commit, err := repo1.GetCommit(testCase.CommitID)
@@ -51,7 +57,8 @@ func testGetCommitsInfo(t *testing.T, repo1 *Repository) {
assert.NoError(t, err)
entries, err := tree.ListEntries()
assert.NoError(t, err)
- commitsInfo, _, err := entries.GetCommitsInfo(commit, testCase.Path, nil)
+ commitsInfo, treeCommit, err := entries.GetCommitsInfo(commit, testCase.Path, nil)
+ assert.Equal(t, testCase.ExpectedTreeCommit, treeCommit.ID.String())
assert.NoError(t, err)
assert.Len(t, commitsInfo, len(testCase.ExpectedIDs))
for _, commitInfo := range commitsInfo {