golang-im聊天
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.
 
 
 
 

42 lines
762 B

  1. package api
  2. import (
  3. "fmt"
  4. "gim/pkg/pb"
  5. "testing"
  6. "google.golang.org/grpc"
  7. )
  8. func getBusinessIntClient() pb.BusinessIntClient {
  9. conn, err := grpc.Dial("localhost:50300", grpc.WithInsecure())
  10. if err != nil {
  11. fmt.Println(err)
  12. return nil
  13. }
  14. return pb.NewBusinessIntClient(conn)
  15. }
  16. func TestUserIntServer_Auth(t *testing.T) {
  17. _, err := getBusinessIntClient().Auth(getCtx(), &pb.AuthReq{
  18. UserId: 3,
  19. DeviceId: 1,
  20. Token: "0",
  21. })
  22. fmt.Println(err)
  23. }
  24. func TestUserIntServer_GetUsers(t *testing.T) {
  25. resp, err := getBusinessIntClient().GetUsers(getCtx(), &pb.GetUsersReq{
  26. UserIds: map[int64]int32{1: 0, 2: 0, 3: 0},
  27. })
  28. if err != nil {
  29. fmt.Println(err)
  30. return
  31. }
  32. for k, v := range resp.Users {
  33. fmt.Printf("%+-5v %+v\n", k, v)
  34. }
  35. }