mirror of
https://github.com/go-gitea/gitea.git
synced 2025-08-21 13:13:27 +00:00
Fix test
This commit is contained in:
parent
0379d4b971
commit
804022bdb5
@ -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
|
||||||
|
@ -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()
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user