dataplatform_test.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package dataplatform
  2. import (
  3. "context"
  4. "net/url"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDataplatformsetParams(t *testing.T) {
  9. convey.Convey("setParams", t, func(ctx convey.C) {
  10. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  11. p1 := d.setParams()
  12. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  13. ctx.So(p1, convey.ShouldNotBeNil)
  14. })
  15. })
  16. })
  17. }
  18. func TestDataplatformGetArchiveByMID(t *testing.T) {
  19. convey.Convey("GetArchiveByMID", t, func(ctx convey.C) {
  20. var (
  21. c = context.Background()
  22. query = ""
  23. )
  24. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  25. ids, err := d.GetArchiveByMID(c, query)
  26. ctx.Convey("Then err should be nil.ids should not be nil.", func(ctx convey.C) {
  27. ctx.So(err, convey.ShouldBeNil)
  28. ctx.So(ids, convey.ShouldNotBeNil)
  29. })
  30. })
  31. })
  32. }
  33. func TestDataplatformSend(t *testing.T) {
  34. convey.Convey("Send", t, func(ctx convey.C) {
  35. var (
  36. c = context.Background()
  37. query = ""
  38. )
  39. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  40. infos, err := d.Send(c, query)
  41. ctx.Convey("Then err should be nil.infos should not be nil.", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. ctx.So(infos, convey.ShouldBeNil)
  44. })
  45. })
  46. })
  47. }
  48. func TestDataplatformSendSpyRequest(t *testing.T) {
  49. convey.Convey("SendSpyRequest", t, func(ctx convey.C) {
  50. var (
  51. c = context.Background()
  52. query = ""
  53. )
  54. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  55. infos, err := d.SendSpyRequest(c, query)
  56. ctx.Convey("Then err should be nil.infos should not be nil.", func(ctx convey.C) {
  57. ctx.So(err, convey.ShouldBeNil)
  58. ctx.So(infos, convey.ShouldBeNil)
  59. })
  60. })
  61. })
  62. }
  63. func TestDataplatformSendBGMRequest(t *testing.T) {
  64. convey.Convey("SendBGMRequest", t, func(ctx convey.C) {
  65. var (
  66. c = context.Background()
  67. query = ""
  68. )
  69. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  70. infos, err := d.SendBGMRequest(c, query)
  71. ctx.Convey("Then err should be nil.infos should not be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. ctx.So(infos, convey.ShouldBeNil)
  74. })
  75. })
  76. })
  77. }
  78. func TestDataplatformNewRequest(t *testing.T) {
  79. convey.Convey("NewRequest", t, func(ctx convey.C) {
  80. var (
  81. c = context.Background()
  82. url = ""
  83. realIP = ""
  84. res = interface{}(0)
  85. )
  86. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  87. err := d.NewRequest(c, url, realIP, d.setParams(), res)
  88. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  89. ctx.So(err, convey.ShouldNotBeNil)
  90. })
  91. })
  92. })
  93. }
  94. func TestDataplatformsign(t *testing.T) {
  95. convey.Convey("sign", t, func(ctx convey.C) {
  96. var (
  97. params url.Values
  98. )
  99. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  100. query, err := d.sign(params)
  101. ctx.Convey("Then err should be nil.query should not be nil.", func(ctx convey.C) {
  102. ctx.So(err, convey.ShouldBeNil)
  103. ctx.So(query, convey.ShouldNotBeNil)
  104. })
  105. })
  106. })
  107. }
  108. func TestDataplatformencode(t *testing.T) {
  109. convey.Convey("encode", t, func(ctx convey.C) {
  110. var (
  111. v url.Values
  112. )
  113. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  114. p1 := d.encode(v)
  115. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  116. ctx.So(p1, convey.ShouldNotBeNil)
  117. })
  118. })
  119. })
  120. }