test1_test.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package test
  2. import (
  3. "app.yhyue.com/moapp/jyMarketing/rpc/activity"
  4. "app.yhyue.com/moapp/jyMarketing/rpc/activityclient"
  5. "app.yhyue.com/moapp/jyMarketing/rpc/internal/config"
  6. "context"
  7. "flag"
  8. "github.com/tal-tech/go-zero/core/conf"
  9. "github.com/tal-tech/go-zero/zrpc"
  10. "log"
  11. "testing"
  12. "time"
  13. )
  14. var configFile = flag.String("f", "activity.yaml", "the config file")
  15. var c config.Config
  16. func init() {
  17. conf.MustLoad(*configFile, &c)
  18. }
  19. //活动下的奖券
  20. func Test_activityLottery(t *testing.T) {
  21. ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
  22. FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
  23. req := &activity.Request{UserId: "ABC", AppId: "123",ActivityId:1}
  24. res, err := FileSystem.ActivityLottery(ctx, req)
  25. log.Println("err ", err)
  26. log.Println("req ", res)
  27. }
  28. //奖券领取
  29. func Test_lotteryReceive(t *testing.T) {
  30. ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
  31. FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
  32. lotteryIdArr:=[]int64{2}
  33. req := &activity.LotteryOperation{UserId: "ABC", AppId: "123",LotteryIdArr:lotteryIdArr}
  34. res, err := FileSystem.LotteryReceive(ctx, req)
  35. log.Println("err ", err)
  36. log.Println("req ", res)
  37. }
  38. //用户下的奖券
  39. func Test_UserLottery(t *testing.T) {
  40. ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
  41. FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
  42. req := &activity.Request{UserId: "ABC", AppId: "123"}
  43. res, err := FileSystem.UserLottery(ctx, req)
  44. log.Println("err ", err)
  45. log.Println("req ", res)
  46. }
  47. //奖券使用
  48. func Test_ActivityUse(t *testing.T) {
  49. ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
  50. FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
  51. lotteryIdArr:=[]int64{2}
  52. req := &activity.LotteryOperation{UserId: "ABC", AppId: "123",LotteryIdArr:lotteryIdArr}
  53. res, err := FileSystem.ActivityUse(ctx, req)
  54. log.Println("err ", err)
  55. log.Println("req ", res)
  56. }