rpc_test.go 790 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package server
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/service/main/passport/conf"
  7. "go-common/app/service/main/passport/model"
  8. "go-common/app/service/main/passport/service"
  9. "go-common/library/log"
  10. "go-common/library/net/rpc"
  11. )
  12. const (
  13. _rpcLoginLogs = "RPC.LoginLogs"
  14. )
  15. func TestRPC_LoginLogs(t *testing.T) {
  16. if err := conf.Init(); err != nil {
  17. panic(err)
  18. }
  19. log.Init(conf.Conf.Xlog)
  20. s := service.New(conf.Conf)
  21. r := New(conf.Conf, s)
  22. defer r.Close()
  23. c2 := rpc.NewDiscoveryCli("passport.service", nil)
  24. time.Sleep(time.Second * 2)
  25. ms := make([]*model.LoginLog, 0)
  26. if err := c2.Call(context.TODO(), _rpcLoginLogs, &model.ArgLoginLogs{
  27. Mid: 88888970,
  28. }, &ms); err != nil {
  29. t.Errorf("failed to call %s, error(%v)", _rpcLoginLogs, err)
  30. t.FailNow()
  31. }
  32. }