order_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package test
  2. import (
  3. "context"
  4. "log"
  5. "testing"
  6. "time"
  7. "app.yhyue.com/moapp/jybase/encrypt"
  8. ordercenterclient "bp.jydev.jianyu360.cn/BaseService/orderCenter/rpc/ordercenter"
  9. "bp.jydev.jianyu360.cn/BaseService/orderCenter/rpc/pb"
  10. "github.com/zeromicro/go-zero/zrpc"
  11. "github.com/zeromicro/go-zero/core/conf"
  12. )
  13. type Config struct {
  14. FileSystemConf zrpc.RpcClientConf
  15. }
  16. var c Config
  17. func init() {
  18. conf.MustLoad("ordercenter.yaml", &c)
  19. }
  20. // go test -v -run Test_GetOrderCode
  21. func Test_GetOrderCode(t *testing.T) {
  22. ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
  23. FileSystem := ordercenterclient.NewOrderCenter(zrpc.MustNewClient(c.FileSystemConf))
  24. req := &pb.GetOrderCodeReq{
  25. Appid: "10000",
  26. }
  27. res, err := FileSystem.GetOrderCode(ctx, req)
  28. log.Println("err ", err)
  29. log.Println("res:", res)
  30. }
  31. // go test -v -run Test_OrderList
  32. func Test_OrderList(t *testing.T) {
  33. ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
  34. FileSystem := ordercenterclient.NewOrderCenter(zrpc.MustNewClient(c.FileSystemConf))
  35. user_id := encrypt.SE.Encode2Hex("47700")
  36. log.Println("user_id=", user_id)
  37. req := &pb.OrderListReq{
  38. Appid: "10000",
  39. UserId: "",
  40. NewUserId: 0,
  41. NewUserIds: user_id,
  42. PageNum: 1,
  43. PageSize: 10,
  44. }
  45. res, err := FileSystem.OrderList(ctx, req)
  46. log.Println("err ", err)
  47. log.Println("res:", res.Data)
  48. log.Println("res:", res.Data.Count)
  49. log.Println("res:", len(res.Data.OrderList))
  50. }