center_test.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. package data
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDataViewerBase(t *testing.T) {
  9. convey.Convey("ViewerBase", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. mid = int64(0)
  13. dt = time.Now()
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. res, err := d.ViewerBase(c, mid, dt)
  17. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldNotBeNil)
  19. ctx.So(res, convey.ShouldBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDataViewerArea(t *testing.T) {
  25. convey.Convey("ViewerArea", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. mid = int64(0)
  29. dt = time.Now()
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. res, err := d.ViewerArea(c, mid, dt)
  33. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldNotBeNil)
  35. ctx.So(res, convey.ShouldBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDataViewerTrend(t *testing.T) {
  41. convey.Convey("ViewerTrend", t, func(ctx convey.C) {
  42. var (
  43. c = context.Background()
  44. mid = int64(0)
  45. dt = time.Now()
  46. )
  47. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  48. res, err := d.ViewerTrend(c, mid, dt)
  49. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldNotBeNil)
  51. ctx.So(res, convey.ShouldBeNil)
  52. })
  53. })
  54. })
  55. }
  56. func TestDataRelationFansDay(t *testing.T) {
  57. convey.Convey("RelationFansDay", t, func(ctx convey.C) {
  58. var (
  59. c = context.Background()
  60. mid = int64(0)
  61. )
  62. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  63. res, err := d.RelationFansDay(c, mid)
  64. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  65. ctx.So(err, convey.ShouldNotBeNil)
  66. ctx.So(res, convey.ShouldNotBeNil)
  67. })
  68. })
  69. })
  70. }
  71. func TestDataRelationFansHistory(t *testing.T) {
  72. convey.Convey("RelationFansHistory", t, func(ctx convey.C) {
  73. var (
  74. c = context.Background()
  75. mid = int64(0)
  76. month = ""
  77. )
  78. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  79. res, err := d.RelationFansHistory(c, mid, month)
  80. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  81. ctx.So(err, convey.ShouldNotBeNil)
  82. ctx.So(res, convey.ShouldNotBeNil)
  83. })
  84. })
  85. })
  86. }
  87. func TestDataRelationFansMonth(t *testing.T) {
  88. convey.Convey("RelationFansMonth", t, func(ctx convey.C) {
  89. var (
  90. c = context.Background()
  91. mid = int64(0)
  92. )
  93. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  94. res, err := d.RelationFansMonth(c, mid)
  95. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  96. ctx.So(err, convey.ShouldNotBeNil)
  97. ctx.So(res, convey.ShouldNotBeNil)
  98. })
  99. })
  100. })
  101. }
  102. func TestDataViewerActionHour(t *testing.T) {
  103. convey.Convey("ViewerActionHour", t, func(ctx convey.C) {
  104. var (
  105. c = context.Background()
  106. mid = int64(0)
  107. dt = ""
  108. )
  109. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  110. res, err := d.ViewerActionHour(c, mid, dt)
  111. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  112. ctx.So(err, convey.ShouldNotBeNil)
  113. ctx.So(res, convey.ShouldBeNil)
  114. })
  115. })
  116. })
  117. }
  118. func TestDataUpIncr(t *testing.T) {
  119. convey.Convey("UpIncr", t, func(ctx convey.C) {
  120. var (
  121. c = context.Background()
  122. mid = int64(0)
  123. ty = int8(0)
  124. now = ""
  125. )
  126. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  127. res, err := d.UpIncr(c, mid, ty, now)
  128. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  129. ctx.So(err, convey.ShouldNotBeNil)
  130. ctx.So(res, convey.ShouldBeNil)
  131. })
  132. })
  133. })
  134. }
  135. func TestDataThirtyDayArchive(t *testing.T) {
  136. convey.Convey("ThirtyDayArchive", t, func(ctx convey.C) {
  137. var (
  138. c = context.Background()
  139. mid = int64(0)
  140. ty = int8(0)
  141. )
  142. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  143. res, err := d.ThirtyDayArchive(c, mid, ty)
  144. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  145. ctx.So(err, convey.ShouldNotBeNil)
  146. ctx.So(res, convey.ShouldBeNil)
  147. })
  148. })
  149. })
  150. }
  151. func TestDataparseKeyValue(t *testing.T) {
  152. convey.Convey("parseKeyValue", t, func(ctx convey.C) {
  153. var (
  154. k = "20060102"
  155. v = "123"
  156. )
  157. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  158. timestamp, value, err := parseKeyValue(k, v)
  159. ctx.Convey("Then err should be nil.timestamp,value should not be nil.", func(ctx convey.C) {
  160. ctx.So(err, convey.ShouldBeNil)
  161. ctx.So(value, convey.ShouldNotBeNil)
  162. ctx.So(timestamp, convey.ShouldNotBeNil)
  163. })
  164. })
  165. })
  166. }