test: cover unpublished content interactions

This commit is contained in:
2026-01-12 10:21:09 +08:00
parent 5031df86f4
commit 9a8dd96b55

View File

@@ -265,6 +265,25 @@ func (s *ContentTestSuite) Test_Interact() {
So(err, ShouldBeNil)
So(len(favs), ShouldEqual, 0)
})
Convey("should reject interactions for unpublished content", func() {
other := &models.User{Username: "user_act2", Phone: "13900000099"}
models.UserQuery.WithContext(ctx).Create(other)
draft := &models.Content{
TenantID: 1,
UserID: u.ID,
Title: "Draft Content",
Status: consts.ContentStatusDraft,
}
models.ContentQuery.WithContext(ctx).Create(draft)
err := Content.AddLike(ctx, tenantID, other.ID, draft.ID)
So(err, ShouldNotBeNil)
err = Content.AddFavorite(ctx, tenantID, other.ID, draft.ID)
So(err, ShouldNotBeNil)
})
})
}