feat: align ids to int64
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"go.uber.org/dig"
|
||||
@@ -126,7 +125,7 @@ func (s *ContentTestSuite) Test_Get() {
|
||||
ctx = context.WithValue(ctx, consts.CtxKeyUser, author.ID)
|
||||
|
||||
Convey("should get detail with assets", func() {
|
||||
detail, err := Content.Get(ctx, author.ID, cast.ToString(content.ID))
|
||||
detail, err := Content.Get(ctx, author.ID, content.ID)
|
||||
So(err, ShouldBeNil)
|
||||
So(detail.Title, ShouldEqual, "Detail Content")
|
||||
So(detail.AuthorName, ShouldEqual, "Author1")
|
||||
@@ -154,7 +153,7 @@ func (s *ContentTestSuite) Test_CreateComment() {
|
||||
form := &content_dto.CommentCreateForm{
|
||||
Content: "Nice!",
|
||||
}
|
||||
err := Content.CreateComment(ctx, u.ID, cast.ToString(c.ID), form)
|
||||
err := Content.CreateComment(ctx, u.ID, c.ID, form)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
count, _ := models.CommentQuery.WithContext(ctx).Where(models.CommentQuery.ContentID.Eq(c.ID)).Count()
|
||||
@@ -219,7 +218,7 @@ func (s *ContentTestSuite) Test_Interact() {
|
||||
|
||||
Convey("Like flow", func() {
|
||||
// Add Like
|
||||
err := Content.AddLike(ctx, u.ID, cast.ToString(c.ID))
|
||||
err := Content.AddLike(ctx, u.ID, c.ID)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Verify count
|
||||
@@ -230,10 +229,10 @@ func (s *ContentTestSuite) Test_Interact() {
|
||||
likes, err := Content.GetLikes(ctx, u.ID)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(likes), ShouldEqual, 1)
|
||||
So(likes[0].ID, ShouldEqual, cast.ToString(c.ID))
|
||||
So(likes[0].ID, ShouldEqual, c.ID)
|
||||
|
||||
// Remove Like
|
||||
err = Content.RemoveLike(ctx, u.ID, cast.ToString(c.ID))
|
||||
err = Content.RemoveLike(ctx, u.ID, c.ID)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Verify count
|
||||
@@ -243,17 +242,17 @@ func (s *ContentTestSuite) Test_Interact() {
|
||||
|
||||
Convey("Favorite flow", func() {
|
||||
// Add Favorite
|
||||
err := Content.AddFavorite(ctx, u.ID, cast.ToString(c.ID))
|
||||
err := Content.AddFavorite(ctx, u.ID, c.ID)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Get Favorites
|
||||
favs, err := Content.GetFavorites(ctx, u.ID)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(favs), ShouldEqual, 1)
|
||||
So(favs[0].ID, ShouldEqual, cast.ToString(c.ID))
|
||||
So(favs[0].ID, ShouldEqual, c.ID)
|
||||
|
||||
// Remove Favorite
|
||||
err = Content.RemoveFavorite(ctx, u.ID, cast.ToString(c.ID))
|
||||
err = Content.RemoveFavorite(ctx, u.ID, c.ID)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Get Favorites
|
||||
@@ -325,7 +324,7 @@ func (s *ContentTestSuite) Test_PreviewLogic() {
|
||||
models.UserQuery.WithContext(ctx).Create(guest)
|
||||
guestCtx := context.WithValue(ctx, consts.CtxKeyUser, guest.ID)
|
||||
|
||||
detail, err := Content.Get(guestCtx, 0, cast.ToString(c.ID))
|
||||
detail, err := Content.Get(guestCtx, 0, c.ID)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(detail.MediaUrls), ShouldEqual, 1)
|
||||
So(detail.MediaUrls[0].URL, ShouldEndWith, "preview.mp4")
|
||||
@@ -334,7 +333,7 @@ func (s *ContentTestSuite) Test_PreviewLogic() {
|
||||
|
||||
Convey("owner should see all", func() {
|
||||
ownerCtx := context.WithValue(ctx, consts.CtxKeyUser, author.ID)
|
||||
detail, err := Content.Get(ownerCtx, author.ID, cast.ToString(c.ID))
|
||||
detail, err := Content.Get(ownerCtx, author.ID, c.ID)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(detail.MediaUrls), ShouldEqual, 2)
|
||||
So(detail.IsPurchased, ShouldBeTrue)
|
||||
@@ -349,7 +348,7 @@ func (s *ContentTestSuite) Test_PreviewLogic() {
|
||||
UserID: buyer.ID, ContentID: c.ID, Status: consts.ContentAccessStatusActive,
|
||||
})
|
||||
|
||||
detail, err := Content.Get(buyerCtx, buyer.ID, cast.ToString(c.ID))
|
||||
detail, err := Content.Get(buyerCtx, buyer.ID, c.ID)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(detail.MediaUrls), ShouldEqual, 2)
|
||||
So(detail.IsPurchased, ShouldBeTrue)
|
||||
@@ -369,7 +368,7 @@ func (s *ContentTestSuite) Test_ViewCounting() {
|
||||
models.ContentQuery.WithContext(ctx).Create(c)
|
||||
|
||||
Convey("should increment views", func() {
|
||||
_, err := Content.Get(ctx, 0, cast.ToString(c.ID))
|
||||
_, err := Content.Get(ctx, 0, c.ID)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
cReload, _ := models.ContentQuery.WithContext(ctx).Where(models.ContentQuery.ID.Eq(c.ID)).First()
|
||||
|
||||
Reference in New Issue
Block a user