diff options
author | zeripath <art27@cantab.net> | 2021-12-21 03:10:16 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-21 11:10:16 +0800 |
commit | 7cc7f0ed75218b061a9529b466ba0eb12954a753 (patch) | |
tree | 36b82b4ea045afdea9337214cdde83eacfd114f1 /modules | |
parent | bef93abd499e7d9d6b63741ecd6b0cd3ab601cf8 (diff) | |
download | gitea-7cc7f0ed75218b061a9529b466ba0eb12954a753.tar.gz gitea-7cc7f0ed75218b061a9529b466ba0eb12954a753.zip |
TestRepository_GetTag intermittently panics due to an NPE (#18043)
There are repeated panics in tests due to TestRepository_GetTag failing
to run properly. This happens when we attempt to reset the internal
repo for a tag which has failed to load. The problem is - the panic that
this is causing is preventing us from finding what the real error is.
This PR simply moves the failure out so we have a chance to see what
really is failing.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/git/repo_tag_test.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/git/repo_tag_test.go b/modules/git/repo_tag_test.go index 136287e1a9..33d34743f8 100644 --- a/modules/git/repo_tag_test.go +++ b/modules/git/repo_tag_test.go @@ -50,9 +50,12 @@ func TestRepository_GetTag(t *testing.T) { aTagID, _ := bareRepo1.GetTagID(aTagName) lTag, err := bareRepo1.GetTag(lTagName) - lTag.repo = nil assert.NoError(t, err) assert.NotNil(t, lTag) + if lTag == nil { + assert.FailNow(t, "nil lTag: %s", lTagName) + } + lTag.repo = nil assert.EqualValues(t, lTagName, lTag.Name) assert.EqualValues(t, lTagCommitID, lTag.ID.String()) assert.EqualValues(t, lTagCommitID, lTag.Object.String()) @@ -61,6 +64,9 @@ func TestRepository_GetTag(t *testing.T) { aTag, err := bareRepo1.GetTag(aTagName) assert.NoError(t, err) assert.NotNil(t, aTag) + if aTag == nil { + assert.FailNow(t, "nil aTag: %s", aTagName) + } assert.EqualValues(t, aTagName, aTag.Name) assert.EqualValues(t, aTagID, aTag.ID.String()) assert.NotEqual(t, aTagID, aTag.Object.String()) |