Skip to content

Commit 7cc7f0e

Browse files
zeripath6543lunnywxiaoguang
authored
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 <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent bef93ab commit 7cc7f0e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/git/repo_tag_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ func TestRepository_GetTag(t *testing.T) {
5050
aTagID, _ := bareRepo1.GetTagID(aTagName)
5151

5252
lTag, err := bareRepo1.GetTag(lTagName)
53-
lTag.repo = nil
5453
assert.NoError(t, err)
5554
assert.NotNil(t, lTag)
55+
if lTag == nil {
56+
assert.FailNow(t, "nil lTag: %s", lTagName)
57+
}
58+
lTag.repo = nil
5659
assert.EqualValues(t, lTagName, lTag.Name)
5760
assert.EqualValues(t, lTagCommitID, lTag.ID.String())
5861
assert.EqualValues(t, lTagCommitID, lTag.Object.String())
@@ -61,6 +64,9 @@ func TestRepository_GetTag(t *testing.T) {
6164
aTag, err := bareRepo1.GetTag(aTagName)
6265
assert.NoError(t, err)
6366
assert.NotNil(t, aTag)
67+
if aTag == nil {
68+
assert.FailNow(t, "nil aTag: %s", aTagName)
69+
}
6470
assert.EqualValues(t, aTagName, aTag.Name)
6571
assert.EqualValues(t, aTagID, aTag.ID.String())
6672
assert.NotEqual(t, aTagID, aTag.Object.String())

0 commit comments

Comments
 (0)