You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
244 lines
4.4 KiB
Go
244 lines
4.4 KiB
Go
package campaignuser
|
|
|
|
import (
|
|
"context"
|
|
"joybuywork/internal/repository/dao"
|
|
"joybuywork/internal/repository/model"
|
|
"joybuywork/internal/repository/withdefault"
|
|
"joybuywork/internal/utils/logic"
|
|
pb "joybuywork/proto/go_proto/w_campaign_user"
|
|
"math/rand"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/rs/xid"
|
|
|
|
_ "joybuywork/test"
|
|
)
|
|
|
|
func TestCampaignUserLottery(t *testing.T) {
|
|
res := &pb.LotteryRes{}
|
|
|
|
container := new(Lottery)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &pb.LotteryReq{
|
|
UserId: 201832,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestVisit(t *testing.T) {
|
|
res := &pb.VisitRes{}
|
|
|
|
container := new(Visit)
|
|
{
|
|
container.Init(context.Background(), logic.WithTran())
|
|
container.Req = &pb.VisitReq{
|
|
Hid: "csl0586rdj7rp2n6h7n0",
|
|
Uid: "1234",
|
|
Cid: "KB",
|
|
Wid: "",
|
|
Lang: "",
|
|
Lv: "",
|
|
Cert: nil,
|
|
Ip: "",
|
|
Platform: "android",
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestReward(t *testing.T) {
|
|
res := &pb.RewardRes{}
|
|
|
|
container := new(Reward)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &pb.RewardReq{
|
|
CampaignHashId: "d2ekiu6rdj7p8kl0tet0",
|
|
IsChild: 1,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestTask(t *testing.T) {
|
|
res := &pb.TaskRes{}
|
|
|
|
container := new(Task)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &pb.TaskReq{
|
|
CampaignId: 4522,
|
|
UserId: 264337141494427648,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestList(t *testing.T) {
|
|
res := &pb.ListRes{}
|
|
|
|
container := new(List)
|
|
{
|
|
container.Init(context.Background())
|
|
container.Req = &pb.ListReq{
|
|
Page: 1,
|
|
PerPage: 10,
|
|
CampaignId: 3906,
|
|
CampaignHashId: "",
|
|
Pid: 0,
|
|
UserMark: "",
|
|
Start: 0,
|
|
End: 0,
|
|
OrderByTimeAsc: false,
|
|
ParentUserMark: "",
|
|
Source: 0,
|
|
LangMark: "",
|
|
TOffset: -100,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestAddUser(t *testing.T) {
|
|
|
|
for k := 0; k < 60; k++ {
|
|
var add []*model.FissionUser
|
|
for i := 0; i < 1000; i++ {
|
|
id := xid.New().String()
|
|
add = append(add, withdefault.FissionUser(&model.FissionUser{
|
|
CampaignID: 3906,
|
|
SubUserID: id,
|
|
UserMark: id,
|
|
UserType: 2,
|
|
Source: int8(rand.Int31n(3) + 1),
|
|
LangMark: "zh",
|
|
}))
|
|
}
|
|
|
|
_ = dao.FissionUser.WithContext(context.Background()).Create(add...)
|
|
}
|
|
}
|
|
|
|
func TestDice(t *testing.T) {
|
|
res := &pb.DiceRes{}
|
|
|
|
container := new(Dice)
|
|
{
|
|
container.Init(context.Background(), logic.WithTran())
|
|
container.Req = &pb.DiceReq{
|
|
UserId: 21637,
|
|
Mark: "",
|
|
Val: "",
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestChild(t *testing.T) {
|
|
res := &pb.ChildRes{}
|
|
|
|
container := new(Child)
|
|
{
|
|
container.Init(context.Background(), logic.WithTran())
|
|
container.Req = &pb.ChildReq{
|
|
CampaignId: 4661,
|
|
UserId: 282913349099614208,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestChildActive(t *testing.T) {
|
|
res := &pb.ChildActiveRes{}
|
|
|
|
container := new(ChildActive)
|
|
{
|
|
container.Init(context.Background(), logic.WithTran())
|
|
container.Req = &pb.ChildActiveReq{
|
|
CampaignId: 4281,
|
|
UserId: 238320997416517632,
|
|
ChildType: 3,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
}
|
|
|
|
func TestAnswer(t *testing.T) {
|
|
res := &pb.AnswerRes{}
|
|
|
|
container := new(Answer)
|
|
{
|
|
container.Init(context.Background(), logic.WithTran())
|
|
container.Req = &pb.AnswerReq{
|
|
UserId: 280395097341292544,
|
|
Submits: []*pb.AnswerReq_Submit{
|
|
{
|
|
Qid: 280392988873060350,
|
|
Aid: []int64{4136701824},
|
|
},
|
|
{
|
|
Qid: 280393044183347200,
|
|
Aid: []int64{4136701824},
|
|
},
|
|
{
|
|
Qid: 280392735583236100,
|
|
Aid: []int64{4013027200},
|
|
},
|
|
{
|
|
Qid: 280392825710440450,
|
|
Aid: []int64{4057034626},
|
|
},
|
|
{
|
|
Qid: 280392916873637900,
|
|
Aid: []int64{4101545858},
|
|
},
|
|
},
|
|
CampaignId: 4664,
|
|
LangMark: "",
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
|
|
}
|
|
|
|
func TestExchange(t *testing.T) {
|
|
|
|
res := &pb.ExchangeRes{}
|
|
container := new(Exchange)
|
|
{
|
|
container.Init(context.Background(), logic.WithTran())
|
|
container.Req = &pb.ExchangeReq{
|
|
UserId: 400613822780043264,
|
|
CampaignId: 5495,
|
|
MallItemId: 394138082718736384,
|
|
}
|
|
container.Res = res
|
|
}
|
|
|
|
t.Log(container.Run(), res)
|
|
|
|
time.Sleep(3 * time.Second)
|
|
}
|