api_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package im
  2. import (
  3. "git.beswell.com/gframe/application"
  4. "github.com/sirupsen/logrus"
  5. "google.golang.org/grpc"
  6. "sportfitness/base/global"
  7. pb "sportfitness/base/repository/grpc/bsw/im/im"
  8. "testing"
  9. )
  10. func init() {
  11. logrus.Info("test init")
  12. app := application.NewDefault()
  13. err := app.AddServiceGrpcClient("bsw/im")
  14. if err != nil {
  15. panic(err)
  16. }
  17. global.SysToken = "3374a2b5a483ed1263f3574666e1ab5e"
  18. }
  19. func TestSignUp(t *testing.T) {
  20. id := SignUpUserCode(&pb.SignUpRequest{
  21. UserCode: "test123",
  22. Name: "测试123",
  23. Email: "",
  24. Phone: "",
  25. WxOpenId: "",
  26. Qq: "",
  27. Password: "123456",
  28. Question: "",
  29. Answer: "",
  30. Memo: "",
  31. })
  32. println(id)
  33. _, err := getClient().SystemAddUser(ctx(), &pb.SystemAddUserRequest{
  34. UserId: id,
  35. Memo: "测试",
  36. })
  37. if err != nil {
  38. panic(err)
  39. }
  40. }
  41. func TestMD(t *testing.T) {
  42. conn, err := grpc.Dial("localhost:19090", grpc.WithInsecure())
  43. if err != nil {
  44. panic(err)
  45. }
  46. client := pb.NewApiClient(conn)
  47. _, err = client.SignInUserCode(ctx(), &pb.SignInPasswordRequest{
  48. Credential: "",
  49. Password: "",
  50. SysId: 0,
  51. ExpirationSec: 0,
  52. Ip: "123123",
  53. ClientInfo: "",
  54. })
  55. _, err = client.SystemAddUser(ctx(), &pb.SystemAddUserRequest{
  56. UserId: 167676470552965120,
  57. Memo: "测试",
  58. })
  59. if err != nil {
  60. panic(err)
  61. }
  62. }
  63. func TestSignInUserCodePassword(t *testing.T) {
  64. token, userId := SignInUserCodePassword(
  65. "test123", "123456", "192.168.0.100", "web")
  66. println(token, userId)
  67. }