client_test.go 762 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package client
  2. import (
  3. "context"
  4. "encoding/json"
  5. "sync"
  6. "testing"
  7. "time"
  8. "go-common/app/service/main/passport/model"
  9. )
  10. var (
  11. once sync.Once
  12. passportSvc *Client2
  13. )
  14. func startRPCServer() {
  15. passportSvc = New(nil)
  16. time.Sleep(time.Second * 2)
  17. }
  18. func TestService2_LoginLogs(t *testing.T) {
  19. once.Do(startRPCServer)
  20. arg := &model.ArgLoginLogs{
  21. Mid: 88888970,
  22. }
  23. if res, err := passportSvc.LoginLogs(context.TODO(), arg); err != nil {
  24. t.Errorf("failed to call rpc, passportSvc.LoginLogs(%v) error(%v)", arg, err)
  25. t.FailNow()
  26. } else if len(res) == 0 {
  27. t.Errorf("res is incorrect, expected res length > 0 but got 0")
  28. t.FailNow()
  29. } else {
  30. for i, v := range res {
  31. str, _ := json.Marshal(v)
  32. t.Logf("res[%d]: %s", i, str)
  33. }
  34. }
  35. }