Skip to content

Commit 804022b

Browse files
committed
Fix test
1 parent 0379d4b commit 804022b

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

models/repo/release.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ func GetReleaseAttachments(ctx context.Context, rels ...*Release) (err error) {
378378
err = db.GetEngine(ctx).
379379
Asc("release_id", "name").
380380
In("release_id", sortedRels.ID).
381+
And("status = ?", db.FileStatusNormal).
381382
Find(&attachments)
382383
if err != nil {
383384
return err

models/user/main_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"testing"
88

99
"code.gitea.io/gitea/models/unittest"
10+
"code.gitea.io/gitea/modules/setting"
11+
"code.gitea.io/gitea/services/attachment"
1012

1113
_ "code.gitea.io/gitea/models"
1214
_ "code.gitea.io/gitea/models/actions"
@@ -15,5 +17,10 @@ import (
1517
)
1618

1719
func TestMain(m *testing.M) {
18-
unittest.MainTest(m)
20+
unittest.MainTest(m, &unittest.TestOptions{
21+
SetUp: func() error {
22+
setting.LoadQueueSettings()
23+
return attachment.Init()
24+
},
25+
})
1926
}

services/issue/comments_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ func Test_DeleteCommentWithReview(t *testing.T) {
3434
// the review should be deleted as well
3535
unittest.AssertNotExistsBean(t, &issues_model.Review{ID: review.ID})
3636
// the attachment should be deleted as well
37-
unittest.AssertNotExistsBean(t, &repo_model.Attachment{ID: comment.Attachments[0].ID})
37+
newAttachment, err := repo_model.GetAttachmentByID(t.Context(), comment.Attachments[0].ID)
38+
assert.Error(t, err)
39+
assert.Nil(t, newAttachment)
3840
}

0 commit comments

Comments
 (0)