cold_test.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package clod
  2. import (
  3. "Cold_Logistic/internal/pkg/common/options"
  4. "context"
  5. "testing"
  6. )
  7. func init() {
  8. options.OptInstance = &options.Options{
  9. BzdClod: &options.BzdOption{
  10. Host: "https://cold.coldbaozhida.com",
  11. DataListUrl: "/api/v3/Data/List",
  12. DeviceSensorList: "/api/v3/DeviceSensor/List",
  13. UserList: "/api/v3/User/List",
  14. LogisticCompanyList: "/api/v3/Company/Transport/List",
  15. },
  16. }
  17. }
  18. func TestBzdClodService_LoginVerification(t *testing.T) {
  19. srv := NewBzdClodService()
  20. tokenKey := "f8904b38-c6fd-48c1-a513-96647abaa880"
  21. ok, pid, user, err := srv.LoginVerification(context.Background(), tokenKey)
  22. if err != nil {
  23. t.Fatalf("err: %v", err)
  24. }
  25. if !ok {
  26. t.Errorf("验证失败")
  27. return
  28. }
  29. t.Logf("pid: %v", pid)
  30. t.Logf("%+v", user)
  31. }
  32. func TestBzdClodService_DeviceSensorList(t *testing.T) {
  33. srv := NewBzdClodService()
  34. got, err := srv.DeviceSensorList(context.Background(), "2023143077448236")
  35. if err != nil {
  36. t.Fatalf("err: %v", err)
  37. }
  38. t.Logf("%v", got)
  39. }
  40. func TestBzdClodService_MonitorDataList(t *testing.T) {
  41. srv := NewBzdClodService()
  42. got, err := srv.DeviceSensorDataList(context.Background(), DeviceSensorDataListParam{
  43. User_tokey: "97b59da7-b9c2-4b39-bd5-b02d53190448",
  44. T_snid: "2023143077448236,0",
  45. Time_start: "2024-2-29 00:00:00",
  46. Time_end: "2024-02-29 15:47:35",
  47. Page: "1",
  48. Page_z: "5",
  49. })
  50. if err != nil {
  51. t.Fatalf("err: %v", err)
  52. }
  53. t.Logf("%v", got)
  54. }
  55. func TestBzdClodService_UserList(t *testing.T) {
  56. srv := NewBzdClodService()
  57. got, err := srv.UserList(context.Background(), UserListParam{
  58. UserToken: "6f37e1cd-0b04-497a-96e4-ad6bc3e81ee9",
  59. Name: "",
  60. Page: 1,
  61. Page_z: 20,
  62. })
  63. if err != nil {
  64. t.Fatalf("err: %v", err)
  65. }
  66. t.Logf("%v", got)
  67. }
  68. func TestBzdClodService_LogisticCompanyList(t *testing.T) {
  69. srv := NewBzdClodService()
  70. got, err := srv.LogisticCompanyList(context.Background(), LogisticCompanyListParam{
  71. UserTokey: "bad2cb8b-bb9a-4541-a751-13c2528f85f2",
  72. TName: "",
  73. Page: 0,
  74. Page_z: 0,
  75. })
  76. if err != nil {
  77. t.Fatalf("err: %v", err)
  78. }
  79. t.Logf("%v", got)
  80. }