api_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package im
  2. import (
  3. "sportfitness/base/global"
  4. pb "sportfitness/base/repository/grpc/bsw/im/im"
  5. "testing"
  6. "git.beswell.com/gframe/application"
  7. "github.com/sirupsen/logrus"
  8. "google.golang.org/grpc"
  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. //
  67. // println(token, userId)
  68. //}
  69. func TestLicenseTypeMap(t *testing.T) {
  70. idList := []int64{165770159456260096}
  71. rs := LicenseTypeMap(
  72. idList)
  73. println(rs)
  74. }