rpcserver_test.go 826 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package server
  2. import (
  3. "flag"
  4. "path/filepath"
  5. "testing"
  6. "time"
  7. _ "time"
  8. "go-common/app/service/main/upcredit/conf"
  9. "go-common/app/service/main/upcredit/service"
  10. "go-common/library/net/rpc"
  11. xtime "go-common/library/time"
  12. )
  13. func init() {
  14. dir, _ := filepath.Abs("../../cmd/upcredit-service.toml")
  15. flag.Set("conf", dir)
  16. }
  17. func initSvrAndClient(t *testing.T) (client *rpc.Client, err error) {
  18. if err = conf.Init(); err != nil {
  19. t.Errorf("conf.Init() error(%v)", err)
  20. t.FailNow()
  21. }
  22. svr := service.New(conf.Conf)
  23. New(conf.Conf, svr)
  24. client = rpc.Dial("127.0.0.1:6079", xtime.Duration(time.Second), nil)
  25. return
  26. }
  27. func TestInfo(t *testing.T) {
  28. client, err := initSvrAndClient(t)
  29. defer client.Close()
  30. if err != nil {
  31. t.Errorf("rpc.Dial error(%v)", err)
  32. t.FailNow()
  33. }
  34. //time.Sleep(1 * time.Second)
  35. }