feat: add post page
This commit is contained in:
@@ -2,10 +2,14 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"quyun/app/service/testx"
|
||||
"quyun/database"
|
||||
"quyun/database/fields"
|
||||
"quyun/database/schemas/public/model"
|
||||
"quyun/database/schemas/public/table"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
@@ -36,8 +40,37 @@ func Test_Posts(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *PostsTestSuite) Test_Demo() {
|
||||
func (s *PostsTestSuite) Test_BatchInsert() {
|
||||
Convey("Test_Demo", s.T(), func() {
|
||||
database.Truncate(context.Background(), db, table.Posts.TableName())
|
||||
|
||||
count := 100
|
||||
for i := 0; i < count; i++ {
|
||||
model := model.Posts{
|
||||
Status: fields.PostStatusPublished,
|
||||
Title: fmt.Sprintf("test-title-%d", i),
|
||||
Description: fmt.Sprintf("test-description-%d", i),
|
||||
Content: fmt.Sprintf("test-content-%d", i),
|
||||
Price: rand.Int63n(10000),
|
||||
Discount: int16(rand.Intn(100)),
|
||||
Views: rand.Int63n(10000),
|
||||
Likes: rand.Int63n(10000),
|
||||
Tags: fields.ToJson([]string{"tag1", "tag2", "tag3"}),
|
||||
Assets: fields.ToJson([]fields.MediaAsset{
|
||||
{
|
||||
Type: fields.MediaAssetTypeAudio,
|
||||
Media: rand.Int63n(10000),
|
||||
},
|
||||
{
|
||||
Type: fields.MediaAssetTypeVideo,
|
||||
Media: rand.Int63n(10000),
|
||||
},
|
||||
}),
|
||||
}
|
||||
|
||||
if err := Posts.Create(context.Background(), &model); err != nil {
|
||||
s.T().Fatal(err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user