This commit is contained in:
Lunny Xiao 2025-07-18 21:13:10 -07:00
parent 0379d4b971
commit 804022bdb5
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 12 additions and 2 deletions

View File

@ -378,6 +378,7 @@ func GetReleaseAttachments(ctx context.Context, rels ...*Release) (err error) {
err = db.GetEngine(ctx). err = db.GetEngine(ctx).
Asc("release_id", "name"). Asc("release_id", "name").
In("release_id", sortedRels.ID). In("release_id", sortedRels.ID).
And("status = ?", db.FileStatusNormal).
Find(&attachments) Find(&attachments)
if err != nil { if err != nil {
return err return err

View File

@ -7,6 +7,8 @@ import (
"testing" "testing"
"code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/services/attachment"
_ "code.gitea.io/gitea/models" _ "code.gitea.io/gitea/models"
_ "code.gitea.io/gitea/models/actions" _ "code.gitea.io/gitea/models/actions"
@ -15,5 +17,10 @@ import (
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
unittest.MainTest(m) unittest.MainTest(m, &unittest.TestOptions{
SetUp: func() error {
setting.LoadQueueSettings()
return attachment.Init()
},
})
} }

View File

@ -34,5 +34,7 @@ func Test_DeleteCommentWithReview(t *testing.T) {
// the review should be deleted as well // the review should be deleted as well
unittest.AssertNotExistsBean(t, &issues_model.Review{ID: review.ID}) unittest.AssertNotExistsBean(t, &issues_model.Review{ID: review.ID})
// the attachment should be deleted as well // the attachment should be deleted as well
unittest.AssertNotExistsBean(t, &repo_model.Attachment{ID: comment.Attachments[0].ID}) newAttachment, err := repo_model.GetAttachmentByID(t.Context(), comment.Attachments[0].ID)
assert.Error(t, err)
assert.Nil(t, newAttachment)
} }