You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 lines
1.2 KiB

  1. package api
  2. import (
  3. "context"
  4. "egg-im/pkg/pb"
  5. "fmt"
  6. "strconv"
  7. "testing"
  8. "time"
  9. "google.golang.org/grpc"
  10. "google.golang.org/grpc/metadata"
  11. )
  12. func getBusinessExtClient() pb.BusinessExtClient {
  13. conn, err := grpc.Dial("im-rpc-business.izhyin.com:8000", grpc.WithInsecure())
  14. if err != nil {
  15. fmt.Println(err)
  16. return nil
  17. }
  18. return pb.NewBusinessExtClient(conn)
  19. }
  20. func getCtx() context.Context {
  21. token := "0"
  22. return metadata.NewOutgoingContext(context.TODO(), metadata.Pairs(
  23. "user_id", "1",
  24. "device_id", "1",
  25. "token", token,
  26. "request_id", strconv.FormatInt(time.Now().UnixNano(), 10)))
  27. }
  28. func TestUserExtServer_SignIn(t *testing.T) {
  29. resp, err := getBusinessExtClient().SignIn(getCtx(), &pb.SignInReq{
  30. PhoneNumber: "18229775311",
  31. DeviceId: 1,
  32. })
  33. if err != nil {
  34. fmt.Println(err)
  35. }
  36. fmt.Printf("%+v\n", resp)
  37. }
  38. func TestUserExtServer_GetUser(t *testing.T) {
  39. resp, err := getBusinessExtClient().GetUser(getCtx(), &pb.GetUserReq{UserId: 2})
  40. if err != nil {
  41. fmt.Println(err)
  42. }
  43. fmt.Printf("%+v\n", resp)
  44. }
  45. func TestUserExtServer_SearchUser(t *testing.T) {
  46. resp, err := getBusinessExtClient().SearchUser(getCtx(), &pb.SearchUserReq{Key: "18229"})
  47. if err != nil {
  48. fmt.Println(err)
  49. }
  50. fmt.Printf("%+v\n", resp)
  51. }