client_test.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package client
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/service/main/location/model"
  7. )
  8. const (
  9. _aid = 16428
  10. _gid = 317
  11. _mid = 0
  12. _ip = "139.214.144.59"
  13. _cip = "127.0.0.1"
  14. )
  15. func TestLocation(t *testing.T) {
  16. s := New(nil)
  17. time.Sleep(1 * time.Second)
  18. testArchive(t, s)
  19. testArchive2(t, s)
  20. testGroup(t, s)
  21. testAuthPIDs(t, s)
  22. testInfo(t, s)
  23. testInfos(t, s)
  24. testInfoComplete(t, s)
  25. testInfosComplete(t, s)
  26. }
  27. func testArchive(t *testing.T, s *Service) {
  28. if res, err := s.Archive(context.TODO(), &model.Archive{Aid: _aid, Mid: _mid, IP: _ip, CIP: _cip}); err != nil {
  29. t.Errorf("Service: archive err: %v", err)
  30. } else {
  31. t.Logf("Service: archive res: %v", res)
  32. }
  33. }
  34. func testArchive2(t *testing.T, s *Service) {
  35. if res, err := s.Archive2(context.TODO(), &model.Archive{Aid: _aid, Mid: _mid, IP: _ip, CIP: _cip}); err != nil {
  36. t.Errorf("Service: archive2 err: %v", err)
  37. } else {
  38. t.Logf("Service: archive2 res: %v", res)
  39. }
  40. }
  41. func testGroup(t *testing.T, s *Service) {
  42. if res, err := s.Group(context.TODO(), &model.Group{Gid: _gid, Mid: _mid, IP: _ip, CIP: _cip}); err != nil {
  43. t.Errorf("Service: group err: %v", err)
  44. } else {
  45. t.Logf("Service: group res: %v", res)
  46. }
  47. }
  48. func testAuthPIDs(t *testing.T, s *Service) {
  49. if res, err := s.AuthPIDs(context.TODO(), &model.ArgPids{IP: _ip, Pids: "2,1163,86,87", CIP: _cip}); err != nil {
  50. t.Errorf("Service: AuthPIDs err: %v", err)
  51. } else {
  52. t.Logf("Service: AuthPIDs res: %v", res)
  53. }
  54. }
  55. func testInfo(t *testing.T, s *Service) {
  56. if res, err := s.Info(context.TODO(), &model.ArgIP{IP: _ip}); err != nil {
  57. t.Errorf("Service: info err: %v", err)
  58. } else {
  59. t.Logf("Service: info res: %v", res)
  60. }
  61. }
  62. func testInfos(t *testing.T, s *Service) {
  63. if res, err := s.Infos(context.TODO(), []string{"61.216.166.156", "211.139.80.6"}); err != nil {
  64. t.Errorf("Service: infos err: %v", err)
  65. } else {
  66. t.Logf("Service: infos res: %v", res)
  67. }
  68. }
  69. func testInfoComplete(t *testing.T, s *Service) {
  70. if res, err := s.InfoComplete(context.TODO(), &model.ArgIP{IP: _ip}); err != nil {
  71. t.Errorf("Service: infoComplete err: %v", err)
  72. } else {
  73. t.Logf("Service: infoComplete res: %v", res)
  74. }
  75. }
  76. func testInfosComplete(t *testing.T, s *Service) {
  77. if res, err := s.InfosComplete(context.TODO(), []string{"61.216.166.156", "211.139.80.6"}); err != nil {
  78. t.Errorf("Service: infosComplete err: %v", err)
  79. } else {
  80. t.Logf("Service: infosComplete res: %v", res)
  81. }
  82. }